3 ms·
When I use JSON, I usually make sure that the parser supports trailing commas and comments, even if I have to add that myself. The reason is that I deal a lot w
by captainmuon 9y ago
When I use JSON, I usually make sure that the parser supports trailing commas and comments, even if I have to add that myself. The reason is that I deal a lot with machine-generated but potentially user-edited JSON. Anything else is needlessly masochistic.
When producing JSON for others, I just use the minimal consensus format (read: the "official" spec).
- drodgers 9y agoI do the same, but instead of switching/patching the JSON parser, I replace it with a YAML one. YAML was designed to be a superset of JSON precisely so that it could be used as an upgrade path. It also allows comments and neat multiline string formatting (in addition to trailing commas).
- captainmuon 9y agoThat is a good option, but YAML is too complex for my taste, with the optional indentation based syntax. JSON + comments, like what sublime text uses for configs, is a sweet spot for me. If you know JS or Python, you can probably write it instinctively.