The proposed extension to JSON, “JSON5“ unfortunately makes me die a little inside. My blog posts rarely adopt this tone, but I feel very strongly about this.
You can read more about JSON5 on the official site but I’m going to have a whinge about why it’s completely pointless and unimaginative poppycock.
The reason behind JSON5
To quote the proposal:
“JSON isn’t the friendliest to write and maintain by hand. Keys need to be quoted; objects and arrays can’t have trailing commas; comments aren’t supported.”
From that you can deduce the following main proposed features:
- Inline comments
- Trailing commas in arrays
- Trailing commas for object properties
There isn’t one. Not one. If anything, this is teaching bad programming techniques:
Property names should be descriptive enough to be obvious without comments, otherwise what you’re doing is probably wrong.
Don’t say “we need to comment our config files”. If your config file requires explanation, do it in the documentation with examples, not inline in your JSON!
This isn’t me getting hung up on old Internet Explorer 6 and 7 parsing, there is simply no need for trailing commas on objects or arrays. Is it worthy of a new spec to add this as a feature?
If it isn’t broken, don’t try to fix it. The approach of the proposal appears to be “what could we add” and seems mainly be suited to less technical people who modify config files.
Of course, I’d love for you to challenge my views…