A modest proposal

                                                       PROPOSED STANDARD
                                                            Errata Exist

Internet Engineering Task Force (IETF) Adam Williamson Request for Comments: 9999 Red Hat Updates: 7159 September 2017 Category: Standards Track ISSN: 9999-9999

 Let Me Put a Fucking Comma There, Goddamnit, JSON

Abstract

Seriously, JSON, for the love of all that is fucking holy, let me end a series of items with a fucking comma.

Comments

Michael wrote on 2017-09-09 13:37:
A better solution is to make items seperable by white space and treat a , like any other form of white space
Almjz wrote on 2017-09-09 13:46:
Yeah, like just get rid of : and {} i mean who needs them all we need is good indenting and we are golden. Lets piss off pythonors while we are at it as well.
Zamicol wrote on 2017-09-09 22:12:
There's json5 for that. json5 is the solution to this problem.
adamw wrote on 2017-09-09 23:25:

It sure looks like a good effort, yeah. Be nice to see wider adoption of it or some other similar effort. Maybe an RFC would help ;)

Przemek Klosowski wrote on 2017-09-11 17:49:
Is this about generating JSON? Because if so, the right idiom is join(',',@list). If you do not have a complete list (e.g. because it is too long, or because you're creating it on the fly), append(',',item) instead of append (item,','). It does require special-casing the first element (if (is_empty(list)) list = element. Trailing comma just looks weird; also, {item,} is different from {item, ''} now?
adamw wrote on 2017-09-11 18:25:

No, it's mostly about human generation. As the json5 description cogently points out, JSON is no longer solely used by bits of code talking to each other; it's commonly used as a configuration format or for other purposes that involve human generation / editing.

(The specific case I ran into which triggered this blog post was that I have a Python project which defines a default value for some element of configuration in Python, and allows modification of it by loading a JSON file; I took the valid Python and saved it as a JSON file as the start point for modifying it, modified it as I wanted, and then it didn't work because of this stupid 'can't end a set of elements with a trailing comma' crap so I had to change that).

"Trailing comma just looks weird"

You are, of course, free not to use one.

"also, {item,} is different from {item, ”} now?"

Of course it is. Those are two very different things. An empty string is very different from...nothing.

Przemek Klosowski wrote on 2017-09-12 14:34:
“Trailing comma just looks weird” You are, of course, free not to use one. “also, {item,} is different from {item, ”} now?” Of course it is. Those are two very different things Right---I meant that when I am looking at your trailing comma I don't know if it's the end of the list or if it has a null last element. 'WTF, Python' has some examples of the surprising results when 0, '', nil, false, {} etc are being operated against each other. Perl is also famous for 'seven forms of FALSE'.