JSON5 Is Pointless and Unimaginative

JSON5

I get excited by new tech, especially when it’s JavaScript related. It usually makes me do a little dance.

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.”

- aseemk

From that you can deduce the following main proposed features:

  • Inline comments
  • Trailing commas in arrays
  • Trailing commas for object properties

The benefits

There isn’t one. Not one. If anything, this is teaching bad programming techniques:

1
2
3
4
5
6
7
8
{
why: [
"is",
"this",
"better",
],
// (it isn't)
}

Inline comments

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!

Commas

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?

Conclusion

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…