bestiejs / json3

A JSON polyfill. No longer maintained.
https://bestiejs.github.io/json3
Other
1.02k stars 150 forks source link

SyntaxError: Unexpected token #92

Closed ghost closed 7 years ago

ghost commented 7 years ago

I know that JSON standard says key of object should be surrounded by double quotation marks. for example, {"key1": "value"}. I want to parse string of "{key: "value"}" to object. notice that there isn't double quotation marks at key. I tried to parse the expression and i can't parse it. but JSON2(by crockford) does

bnjmnt4n commented 7 years ago

Since the key does not have double quotation marks, it is not valid JSON, and thus JSON 3 will not parse it. JSON 2 does not ensure the text passed in is valid and will be able to parse it as it uses eval.