←back to thread

Fixing JSON

(www.tbray.org)
139 points robin_reala | 2 comments | | HN request time: 0.438s | 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. shill ◴[] No.12327829[source]
My assumption is that quotes are needed for keys with spaces.

    > x = {}
    > x["foo bar"] = 1
    > x
    { 'foo bar': 1 }
replies(1): >>12334340 #
2. Retra ◴[] No.12334340[source]
That only explains why they are permitted, not why they are mandatory.