Closed Bug 935199 Opened 11 years ago Closed 10 years ago

Inaccuracy on JSON documentation page

Categories

(Developer Documentation Graveyard :: JavaScript, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: richard.gibson, Assigned: bruant.d)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/28.0.1500.71 Chrome/28.0.1500.71 Safari/537.36

Steps to reproduce:

Visited https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON


Actual results:

I read "It is based upon JavaScript syntax but is distinct from it: some JavaScript is not JSON, and some JSON is not JavaScript".


Expected results:

Something more like "It is a strict subset of JavaScript syntax: not all JavaScript is JSON".
It's suggested that it's not the case because of U+2028 and U+2029
https://twitter.com/mathias/status/398002300603891712
https://twitter.com/mathias/status/398002709246533632

var code = '"\u2028\u2029"';
JSON.parse(code); // works fine
eval(code); // fails

I'm keeping the bug open, because a note should be added to explain this special case.
Perfect! Thanks.
I have added the sample from comment 1 to the page and also a link to http://timelessrepo.com/json-isnt-a-javascript-subset which explains it pretty good I would say. Feel free to review and enhance the wiki page, if you like.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.