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.
A better solution is to make items seperable by white space and treat a , like any other form of white space
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.
There’s json5 for that.
json5 is the solution to this problem.
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 😉
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?
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.
“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’.