3 ms·
Speaking of new JSON versions, is it impossible to create a backwards-compatible JSON spec that supports comments? I've been waiting for this for ages.
by arturadib 15y ago
Speaking of new JSON versions, is it impossible to create a backwards-compatible JSON spec that supports comments? I've been waiting for this for ages.
- jsdalton 15y agoPlease, yes. Two use cases where I constantly bemoan the lack of comment support in JSON are configuration files and test fixtures.
- kitcambridge 15y agoI, too, would love to see comments officially supported in the next iteration of the JSON standard...IIRC, Crockford removed them to make JSON a valid YAML subset. For what it's worth, I've created a fork of Kyle Simpson's `JSON.minify` project that uses a variation of the character-based parsing process in JSON 3: https://github.com/kitcambridge/JSON.minify/blob/master/minify-sans-regexp.js https://github.com/kitcambridge/JSON.minify/blob/master/mini... It's somewhat cumbersome to use, though, as it needs to be called on a string before feeding it to `parse` (e.g., `JSON.parse(JSON.minify("/* Hello */ 123"))`).
- kodablah 15y agoOptional quotes and optional EOL commas would be nice too
- akavlie 15y agoWhile more human friendly, that would inhibit serialization.
- wvenable 15y agoComments were removed for several reasons; one being that it adds the ability to add non-JSON data to the stream. In order to keep the spec simple and more interoperable, comments are gone. Don't expect them to return.