3 ms·
JSON with comments would go a long way
by ithkuil 1y ago
JSON with comments would go a long way
- krapp 1y agoUse Lua tables. Lua's parser is smaller than many JSON parsers, the syntax is almost the same and you can use comments.
- Bolwin 1y agoOn the web? In wasm? I'd much rather use a new format. MAML's parser is 2kb of js gzipped according to the repo and very fast.
- krapp 1y agoIf that matters, the just bite the bullet and use JSON, which is supported in every browser in existence and has a parser library in every language worth using.
- petersumskas 1y agoDouglas Crockford addressed this many years ago: write your human readable config with comments and run it through a pre-processor to strip them out before handing the config to a JSON parser. Seems like almost no one picked up on the idea.
- ulrikrasmussen 1y agoThat is such a horrible non-solution. It breaks all tooling which isn't aware of your particular preprocessor and adds a compilation step to every configuration.
- benhurmarcel 1y ago> write your human readable config with comments The question then becomes: what format is that?
- seanhunter 1y ago> Seems like almost no one picked up on the idea. Seems to me more like almost no one thought the idea was any good.
- zzo38computer 1y agoThat avoids one of the benefits of having a text based format; I would use TER and convert to DER (where TER is a text format and DER is a binary format, and which is what I do with some of my programs). (Text formats do have some benefits, but binary formats have different benefits.)
- sebazzz 1y agoJSON5 is what that is called and it already has wide support.
- Too 1y agoThis is answered in the FAQ
- jcarrano 1y agoUse a '$comment' key in objects, which has the advantage of being preserved across a decoding-encoding round-trip.