Inaccuracy on JSON documentation page

RESOLVED FIXED

Status

RESOLVED FIXED
5 years ago
5 years ago

People

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

Tracking

Details

(Reporter)

Description

5 years ago
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".
(Assignee)

Comment 1

5 years ago
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.
(Reporter)

Comment 2

5 years ago
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
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.