> Yes, Doug Crockford deliberately removed comments from JSON but people keep putting them back in. If we’re going to have comment-enriched JSON (e.g. for human-editable configuration files), we might as well have a standard one. The text "deliberately removed comments from JSON" links to https://web.archive.org/web/20150105080225if_/https://plus.g... where Doug not only explains the reason, but also a solution which…
Crockford regularly displays a stunning degree of tunnel vision. Without a standard format for comments, you have no reason whatsoever to expect the ad-hoc comments in a JSON file made by anyone who isn't you to be styled like JavaScript comments. And if your response is "then everyone needs to use JavaScript-style comments", well, TA-DA, you've just added comments to the spec. You can't have it both ways. > It's imp…
JSON with Commas and Comments
11–20 of 251 posts
Re: JSON with Commas and Comments
#12{ [1, 2]: "a", [3, 4]: "b" }
Re: JSON with Commas and Comments
#13Re: JSON with Commas and Comments
#14IMO it would also be really nice to have non-string keys in objects, like: { [1, 2]: "a", [3, 4]: "b" }
Re: JSON with Commas and Comments
#15See also: https://json5.org https://github.com/json5/json5
Re: JSON with Commas and Comments
#16Here's another flavour of JSON with comments: https://pypi.org/project/commentjson/
Re: JSON with Commas and Comments
#17Earlier quoted context omitted.
Crockford regularly displays a stunning degree of tunnel vision. Without a standard format for comments, you have no reason whatsoever to expect the ad-hoc comments in a JSON file made by anyone who isn't you to be styled like JavaScript comments. And if your response is "then everyone needs to use JavaScript-style comments", well, TA-DA, you've just added comments to the spec. You can't have it both ways. > It's imp…
If the rules are unspecified the only thing you wouldn't be able to put in comments are what is specified as JSON syntax. If you add minimal specifications for escape sequences then even that is allowed.
Indeed.
Re: JSON with Commas and Comments
#18Rather than keep making new variants of JSON, it'd be nice if somebody could convince some mainstream language maintainers to just update their built-in JSON parser to add optional features like skipping over comments and not caring about trailing commas. Most parsers support various flags already to configure things, so there could just be an ALLOW_COMMENTS flag and ALLOW_TRAILING_COMMAS flag. As a case in point, th…
Re: JSON with Commas and Comments
#19Rather than keep making new variants of JSON, it'd be nice if somebody could convince some mainstream language maintainers to just update their built-in JSON parser to add optional features like skipping over comments and not caring about trailing commas. Most parsers support various flags already to configure things, so there could just be an ALLOW_COMMENTS flag and ALLOW_TRAILING_COMMAS flag. As a case in point, th…
I wish something would done in this area relatively soon though because JS has added a number of features that would make a new JSON much nicer like multi-line strings and BigInts.
I think JSON + comments, commas, template literals, BigInt, NaN, Infinity, and BigDecimals (if/when those land in JS) would be very useful. (It'd be nice to include dates, but that's tricky w/o a literal and because dates)