The JSON spec says that JSON is an object or an array. In the case of an object,
An object structure is represented as a pair of curly brackets
surrounding zero or more name/value pairs (or members). A name is a
string. …
And later, the spec says that a string is surrounded in quotes.
Why?
Thus,
{"Property1":"Value1","Property2":18}
and not
{Property1:"Value1",Property2:18}
Question 1: why not allow the name in the name/value pairs to be unquoted identifiers?
Question 2: Is there a semantic difference between the two representations above, when evaluated in Javascript?
The design philosophy of JSON is “Keep it simple”
“Quote names with
"“ is a lot simpler than “You may quote names with"or'but you don’t have to, unless they contain certain characters (or combinations of characters that would make it a keyword) and'or"may need to be quoted depending on what delimiter you selected”.No. In JavaScript they are identical.