4 ms·
If anything, trailing commas would actually be nice. It won't complicate parsing, but it does make the automatic generation of JSON much nicer as you no longer
by spc476 13y ago
If anything, trailing commas would actually be nice. It won't complicate parsing, but it does make the automatic generation of JSON much nicer as you no longer have to specially treat the first or last element of an array or object.
The rest of the changes I'm not so keen on.
- masklinn 13y ago> it does make the automatic generation of JSON much nicer Are you generating JSON as freeform text? Because a call to JSON.stringify (or whatever JSON-dumping method exists in your language of choice) would not be "made nicer" by handling trailing commas.
- spc476 13y agoHow so?
- masklinn 13y agoBecause the tool handles generation so you don't give a damn whether the final format uses trailing commas or not? And you can use trailing commas in your source language if that's supported?
- spc476 13y agoAh, I see. You are assuming a JSON encoder exists for a given language. I'm not.
- shirro 13y agoI have hand written a fair amount of json in the last week including some json schemas and the trailing commas gets me coming from golang literals and back. I don't mind the idea of alternate syntaxes that compile to json in the spirit of coffeescript or less/sass/haml etc. Coffeescript makes it very clear that it is just an alternate syntax for javascript. If that is the aim of json5 that is cool. I just don't want to see public APIs producing and consuming json5 in the wild and breaking stuff.
- TazeTSchnitzel 13y agoIf you're generating JSON with string concatenation instead of using a JSON serializer, you're almost certainly doing something wrong.