←back to thread

Fixing JSON

(www.tbray.org)
139 points robin_reala | 1 comments | | HN request time: 0.001s | source
Show context
pluma ◴[] No.12329905[source]
In my opinion there are five problems with JSON in practice:

1. Trailing commas should be allowed. This would fix the entire comma ordeal the author is complaining about without introducing awkward whitespace logic.

2. Date time values should be a distinct type using the format of JS's Date.prototype.toISOString method. Had this been in the language when JSON was originally defined I'm sure it'd already be in JSON.

3. There should be a way to represent Infinity (for IEEE 754 compatibility) and possibly NaN.

4. Comments would be nice because JSON is often used for configuration and documenting JSON snippets can get awkward without them.

5. There's no real way to represent binary data other than base64 encoded strings. It would be nice if there was at least some hex format (e.g. `"blob": <dead beef cafe babe>` with optional spaces for readability) but I can see why some people might be opposed to the idea of adding this to the language

replies(4): >>12330188 #>>12330375 #>>12330613 #>>12330688 #
grandinj ◴[] No.12330613[source]
Yes and double yes to comments!

Otherwise it's useless as a configuration language

replies(1): >>12330620 #
sneak ◴[] No.12330620[source]
I used to think this, too.

Turns out, there is a really good reason for the lack of comments in JSON.

replies(1): >>12330737 #
majewsky ◴[] No.12330737[source]
Which is?
replies(1): >>12330966 #
1. cprecioso ◴[] No.12330966[source]
To avoid them being used as parser directives.