←back to thread

Fixing JSON

(www.tbray.org)
139 points robin_reala | 1 comments | | HN request time: 0.289s | source
Show context
greenyoda ◴[] No.12327716[source]
I never understood why the double quotes around property names are mandatory. For example, in JavaScript, I can write

    { foo: 1, bar: 2 }
but JSON syntax insists on

    { "foo": 1, "bar": 2 }
This makes JSON less easily readable by humans, and harder to write or edit by hand.

Anyone know why JSON was designed this way?

replies(6): >>12327762 #>>12327775 #>>12327805 #>>12327829 #>>12327836 #>>12327945 #
1. nemild ◴[] No.12327775[source]
I don't know the history of why design decisions were made in JSON, but one might be the allowance for spaces in keys and mirroring the usage within arrays (where commas and spaces may be used in a string, but shouldn't be confused with a record separator).

Per my other comment, there are a variety of plugins on the editor side that will make JSON look like this (e.g., vim-json ). To write out to JSON from that format, you can obviously just write a plugin (in JS this is one line).