r/programming • • Feb 25 '21

An Exploration of JSON Interoperability Vulnerabilities

https://labs.bishopfox.com/tech-blog/an-exploration-of-json-interoperability-vulnerabilities
128 Upvotes

39 comments sorted by

View all comments

Show parent comments

26

u/evaned Feb 25 '21

Lots of things use JSON for configuration files and other things intended to be hand-written, as I'm sure you've noticed. Tools have been "updated" to support that use, which hugely benefits from comments, to the point of it turning a terrible language for that purpose into one that's usually merely mediocre.

As for why JSON is used there instead of INI or TOML something... well that I think mostly falls into "everything is terrible" category.

13

u/[deleted] Feb 25 '21

I think JSON is better than TOML for configuration purposes except for the fact that it often doesn't support comments and trailing commas (cough package.json) and it isn't clear when it does and when it doesn't. JSON5 solves that problem but isn't as widely supported.

TOML is ok, but it still has more weird quirks and is less obvious than JSON (but way better than YAML).

In particular the [[table]] syntax is very unintuitive, to the point that I still don't understand it. JSON arrays are blindingly obvious.

Another weirdness is that you can put a table in braces, but only if it is all on one line! Another thing JSON got right.

For all its limitations JSON is probably the best thing to come out of JavaScript. It got a lot right.

-1

u/ForeverAlot Feb 26 '21

I think JSON is better than TOML for configuration purposes except for the fact that it often doesn't support comments and trailing commas (cough package.json) and it isn't clear when it does and when it doesn't.

It is perfectly clear when JSON supports comments: never.

4

u/[deleted] Feb 26 '21

Ok nitpicker, it isn't clear when a file is JSON and when it is JSONC.