by furyofantares · 4y ago · 0 comments
There may be a tiny bit of signal in such comments but it's mostly just noise. I try to just ignore any comment that looks like the commenter just wrote whatever came to their mind, they're gonna forget about it in 10 seconds too when they're off to the next thing to react to.
JSON is useful partially because it’s easy to parse, so parsers already exist in every language. Extending the syntax is undoing all the communal work, and encroaching on grounds that YAML and other languages already cover.
> Extending the syntax is undoing all the communal work
JSON5 takes stuff from ES5.1 and adds it to JSON, and ES5 is backwards-compatible with older JS. This means it's fairly trivial to convert JSON5 to JSON (literally 13 lines: https://gist.github.com/iddan/3d34b12f6b22c30a8a07c149b3175e...). And ES5.1 itself was the product of communal work.
> encroaching on grounds that YAML and other languages already cover.
I don't know that we should really start dividing features into nice little boxes so no one steps on each other's toes. Trying different solutions for the same problem can eventually bring us more optimal solutions than if we just sat around twiddling our thumbs because 'it's been done'. It's not like there's an army knocking on your door going "switch to JSON5 or we'll kick your teeth in." People can stick with what they want to do on the merits, but I don't see that as a reason to shut down others' work.
This take is disingenuous and horribly uninformed and very shortsighted.
Not every parser out there is JavaScript eval(). Some people actually had to write and maintain a parser in whatever programming language they have to work with.
In the past I wrote a JSON parser for a low-level language, and back then I had to write the letter and parser by hand. Each change to accepted JSON values meant I had to add at least one terminal token, update the grammar to include it, and update the data model to support yet another type.
Adding comments would either require adding a terminal token to be ignored, or rewrite the data model to support positional items that cursors/iterators could or could not skip.
These are not 13LoC changes. At all.
And if I happen to be consuming an API I don't control which for God knows what reason decided to move to json5, I would either have to rush a parser to production or remain down.
You can disagree with someone without accusing them of being insincere or arguing in bad faith (which is what “disingenuous” means).
> And if I happen to be consuming an API I don't control which for God knows what reason decided to move to json5
And such a decision might be the API maintainers not understanding their users.
Did you paste the correct link? This just plumbs together an existing JSON 5 parser with a JSON 4 serializer.
How many lines does this take without importing a library the solves this for you?
JSON.stringify is part of the standard JS spec: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
JSON5.parse() is part of JSON5's API: https://json5.org/#json5parse
So any project that includes both standard JS and JSON5 could literally copy and paste this code. You're still importing JSON5, but you would presumably have to do that anyways to use JSON5.
Since this behavior is so common, apparently it works, evolutionary:
It makes others think your are smart, for a long while
And not much effort required, on your part. So, a great opportunity?
And the more popular the project you start bashing is, the smarter you'll seem? Corollary: If one builds something great, one will get dissed by some.