Live data from Hacker News

JSON with Commas and Comments

nigeltao.github.io

31–40 of 251 posts

Re: JSON with Commas and Comments

#31

Earlier 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…

I wish JSON supported comments, but I don’t really understand your criticism. You say: > 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. But, since comments are not supported in JSON, you can expect JSON from external sources to contain no comments whatsoever. That’s precisely Crockfo…

I can't believe that anyone who has ever wanted to comment a package.json file could think Crockford's argument is anything but nonsense. The problem is these files are both edited by humans, and by a plethora of tools. Without a standard comment format, it's been a nightmare trying to comment package.json file in a way that doesn't break something in the NPM/Node ecosystem.

Re: JSON with Commas and Comments

#32
post #15

Earlier quoted context omitted.

Combining effort with JSON5 (~4K GitHub stars) makes sense to me.

They explicitly do not want unquoted keys. The author reviewed most prior art in TFA.

You can say this without using that acroynm.

Please review https://news.ycombinator.com/newsguidelines.html.

Re: JSON with Commas and Comments

#33
post #21

Earlier quoted context omitted.

You realize this would push outside of what JavaScript provides? 'Welcome to Node.js v15.7.0. Type ".help" for more information. > { [1, 2]: "a" } ({ [1, 2]: "a" }) ^ Uncaught SyntaxError: Unexpected token ',' Thar' be dragons! https://stackoverflow.com/questions/32660188/using-array-obj...

it's true JS doesn't support this, and it's also true that any JSON that supported it would therefore no longer be _JavaScript_ object notation. However, it's equally true that a better language and object notation would support non-string scalar keys.

JavaScript wouldn't be able to consume those resulting objects, so it would be pretty diminished as an alternative to JSON. Object keys are all strings.

Re: JSON with Commas and Comments

#34

Earlier quoted context omitted.

I wish JSON supported comments, but I don’t really understand your criticism. You say: > 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. But, since comments are not supported in JSON, you can expect JSON from external sources to contain no comments whatsoever. That’s precisely Crockfo…

I can't believe that anyone who has ever wanted to comment a package.json file could think Crockford's argument is anything but nonsense. The problem is these files are both edited by humans, and by a plethora of tools. Without a standard comment format, it's been a nightmare trying to comment package.json file in a way that doesn't break something in the NPM/Node ecosystem.

The fact that lots of people want to comment their package.json file and can’t easily due to Crockford’s decision does not mean that Crockford’s argument is nonsense. Crockford’s argument is not that there shouldn’t be comments in JSON because no one would want to use them. And again, I would also like to have comments in JSON.

Re: JSON with Commas and Comments

#35
post #21

Earlier quoted context omitted.

You realize this would push outside of what JavaScript provides? 'Welcome to Node.js v15.7.0. Type ".help" for more information. > { [1, 2]: "a" } ({ [1, 2]: "a" }) ^ Uncaught SyntaxError: Unexpected token ',' Thar' be dragons! https://stackoverflow.com/questions/32660188/using-array-obj...

it's true JS doesn't support this, and it's also true that any JSON that supported it would therefore no longer be _JavaScript_ object notation. However, it's equally true that a better language and object notation would support non-string scalar keys.

I can see why you want non-string scalar keys. In general, I do too. (I'm writing a data language that has them.)

However, I don't think it is useful to prod JSON (or a variant) to go in this direction.

Re: JSON with Commas and Comments

#36

Rather 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…

It's going to have to be a different mode and mimetype because this format would break all kinds of parsers. 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 ver…

JSON doesn’t specify its numeric types: the mapping of a string of digits to concrete numeric types is implementation-defined: so, JSON doesn’t need specific syntax for BigInts or arbitrary-precision decimals.

Re: JSON with Commas and Comments

#37

Earlier 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…

I wish JSON supported comments, but I don’t really understand your criticism. You say: > 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. But, since comments are not supported in JSON, you can expect JSON from external sources to contain no comments whatsoever. That’s precisely Crockfo…

You can expect JSON from external sources to be a JSON like notation their parser accepts. Not JSON always.

Re: JSON with Commas and Comments

#38
post #24

Earlier quoted context omitted.

They explicitly do not want unquoted keys. The author reviewed most prior art in TFA.

Would you like to spell out what TFA means?

People use TFA (the fine/featured article) without malice here. I apologize that I did not convey my spirit adequately.

Re: JSON with Commas and Comments

#39
post #30
post #28

Earlier quoted context omitted.

https://en.wiktionary.org/wiki/RTFA

I'm aware, thanks. I wanted to see if CameronNemo would spell it out. I'd like to point out the HN Guidelines: https://news.ycombinator.com/newsguidelines.html > Please don't comment on whether someone read an article. "Did you even read the article? It mentions that" can be shortened to "The article mentions that." Even putting aside what "F" stands for, this means that comments like TFA or RTFA are not in the spiri…

"TFA" is a common usage on HN just to neutrally mean "the article that this comment page is about". It doesn't by itself imply "RTFA".

Re: JSON with Commas and Comments

#40
post #28
post #24

Earlier quoted context omitted.

Would you like to spell out what TFA means?

https://en.wiktionary.org/wiki/RTFA

I did not intend this spirit. Instead I wanted to constructively point out that the article reviews several Json quirks and supersets.
Post reply on HN