←back to thread

Fixing JSON

(www.tbray.org)
139 points robin_reala | 1 comments | | HN request time: 0.207s | source
Show context
ambrop7 ◴[] No.12327865[source]
Two more issues:

- No support for comments.

- No support for NaN and Infinities (i.e. lack of full mapping to IEEE 754).

Also at least on Chrome, JSON.stringify(-0) gives 0, though JSON.parse("-0") does give -0. Weird..

As far as schemas are concerned, I find it nicer to not use schemas but access the JSON through an interface that checks things on the fly (types, existence), effectively verifying the JSON while you're examining it. E.g. things like x.get_int('name'), which throws exception if it doesn't exist or isn't an integer. Possibly even with an error message explaining where exactly and what is wrong (like: foo.bars[4].bazes["abc"]: attribute "qux" does not exist).

replies(1): >>12330881 #
1. ksherlock ◴[] No.12330881[source]
The original JSON spec included comments. They were removed because people were using them as processing directives.