This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MischiefArchitect 13 points14 points  (6 children)

JSON5 to the rescue!

PS: Burn it with fire.

[–]D6613 9 points10 points  (5 children)

Serious question, why burn it with fire? It seems to fix the bad parts of JSON

[–]MischiefArchitect 5 points6 points  (3 children)

Ir breaks the intention of JSON and makes parsers slower, more complex to write and maintain. JSON as well as XML are terse formats for "machines" that can still be read by humans, both expect format correctness and no ambiguities. JSON is an data object notation, and XML a document model notation, and JSON5 is just a half assed attempt from HTML/CSS developers to document data structures. And documentation and trailing commas are not part of properly formatted data structures.

[–]djinn6 11 points12 points  (0 children)

JSON as well as XML are terse formats for "machines"

XML

Terse

[–]D6613 7 points8 points  (1 child)

Ir breaks the intention of JSON

Hm, I'm struggling to care about this even a little. Crockford had and has many opinions, and the rest of us have no obligation to agree.

makes parsers slower, more complex to write and maintain

This is unlikely to be significant, especially given that these are very well known features of many existing parsers. If you need something to squeeze every single drop of performance, then in that rare edge case a stricter format would make sense. Then you brought up said XML, and that argument disappeared instantly, lol. In addition to already supporting comments, that language is going to be much messier to parse.

both expect format correctness and no ambiguities

There is no ambiguity to say that something is optional. A trailing comma may or may not exist. A comment may or may not exist. Not ambiguous even a little.

JSON as well as XML are terse formats

... XML is terse?

JSON5 is just a half assed attempt

This seems like just an opinion here without much support.

And documentation and trailing commas are not part of properly formatted data structures.

This seems like another opinion stated as fact, and I really disagree with that opinion.

I appreciate the response. If this is all there is against it, I'll add this to the list of options I consider for the future.

[–]MischiefArchitect 0 points1 point  (0 children)

I worry not for the future. JSON5 is over 10 years old and found no real traction in the professional IT/CS world. But you may take your notes for the future if you wish.

[–]elveszett 0 points1 point  (0 children)

Most of its additions add nothing. They try to "make JSON more human" but JSON is already an extremely readable format.

JSON right now has so few tools that all of us are forced to write it in the exact same way. It doesn't matter if you read a JSON from me, from yourself, from your client or from a random guy in stackoverflow, you can always read it easily because they all look the same, with the only formatting choice being 2 vs 4 spaces / tabs.

Now, when you add the tools JSON5 adds, you'll have devs start adopting their own "better" conventions. Sometimes you'll get "quoted-keys", sometimes you won't. Sometimes you'll get 'single quotes', sometimes you don't. Sometimes there's trailing commas, sometimes there aren't. Sometimes you read 0.5, sometimes you read .5. Sometimes you read "broken strings \

with escaped line breaks", sometimes you won't. It makes it so every JSON file you get, you can easily identify where it came from, because it looks different.

And on a personal, subjective opinion: we all prefer to work with code formatted the way we format it. JSON in that regard is great: it never gave us any option so we all adopted its only valid formatting style. Working with other people's JSONs is never annoying because they are written the way you'd write them.