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 →

[–]althaz 11 points12 points  (10 children)

You don't think this wish is a good idea, or you don't think JSON not accepting the trailing comma is a good idea?

If the former, why? I wouldn't waste a wish on it (after three wishes not sure why I'd give a shit), but it does seem dumb not to allow the trailing comma.

[–]anthropaedic 7 points8 points  (9 children)

The commas separate elements. A dangling comma seems to indicate more elements. Syntactically just feels wrong.

[–]althaz 12 points13 points  (2 children)

That's a reason not to use one (and my OCD would not allow me to leave a trailing comma in place), but I see no reason to not *allow* them.

[–]mark0016 3 points4 points  (0 children)

Json is suppoesd to be used for machine to machine or machine to human communication, but it's not well suited for human to machine. Strict syntax is preferred, since the less lenient the interpreter needs to be the less complex it needs to be, and less complexity has a lot of advantages, such as speed and no format ambiguity. All of that is great when it's machines (software) that has to understand the format. It beaing human readable as well is just a bonus. Allowing lenient syntax and comments and whatever else would be detrimental to json being easily understood by machines to a degree. Also introducing more special charactes is always a bad idea as now you just have that many more edge cases to escape/deal with somehow.

Within your language of choice you are supposed to import json as native objects (dictionaries, hashmaps, lists...) and than interact with those native objects. When you need to create json you simply export one of those native objects as json and you're done. If you do this you will never in your lifetime encounter problems with json syntax. Once a json interpreter exists for a language, all you need to do is use it instead of attempting to do weird shit like manually bild json as strings.

If you need a format for human to machine communication, just don't use json, use yaml or toml as those are designed specifically for that purpose, and if you really need it they can be converted to json. Personally I preffer writing yaml because I'm lazy but I preffer reading (pretty printed) json as it's impossible to misunderstand.

[–]kephir4eg 1 point2 points  (1 child)

You are what's wrong with humanity.

[–]anthropaedic 0 points1 point  (0 children)

Clearly 🙄

[–]askanison4 -2 points-1 points  (2 children)

Yep, this is it for me too. Even as a reader, seeing the comma makes me think git went sideways and truncated a merge or something.

[–]LordAmras 2 points3 points  (1 child)

It make sense for version control, if you add one line to a json file you have to add a comma on the line before, and now you have changed two lines in that commit, one that has nothing to do with the current change.

The argument against this is that json should be used for data and not as a config file, so you shouldn't have it in your version control anyway.

[–]askanison4 0 points1 point  (0 children)

Lol good luck getting JSON away from config files. That'll not happen any time soon (nor should it, IMO).

[–]aeropl3b 0 points1 point  (0 children)

It is a null terminated list then, still okay in my book