←back to thread

Fixing JSON

(www.tbray.org)
139 points robin_reala | 1 comments | | HN request time: 0.203s | 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 #
1. tofflos ◴[] No.12330375[source]
6. I'd love to see unquoted keys added to that list. Quotes could be used for cases when a key is not a valid identifier.