Feature Request: Make ECMA262 a superset of JSON

Richard Gibson richard.gibson at gmail.com
Thu Sep 29 21:21:29 UTC 2016


ECMAScript claims JSON as a subset twice in
https://tc39.github.io/ecma262/#sec-json.parse , but (as has been
well-documented) that is not true because it JSON strings can contain
unescaped U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR while
ECMAScript strings cannot. Mark Miller alludes to a pre-ES5 push for
allowing them (which ultimately failed) in
https://esdiscuss.org/topic/json-stringify-script#content-17 , and posits
that a repeat today would also fail. Having never seen a windmill that
didn't need slaying, I hereby make the attempt.

Aside from slightly simplifying the spec (by eliminating the need for a
production specific to JSON.parse) and retroactively validating its claims,
such a change to _DoubleStringCharacter_ and _SingleStringCharacter_ would
allow safely embedding arbitrary JSON directly within ECMAScript, a request
which has been made before in the context of source
concatenation/construction.

User-visible effects from the change would be limited to the absence of
SyntaxError s from code like `eval(' "\u2028" ')` or its raw-text
equivalent.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160929/72b25f98/attachment.html>


More information about the es-discuss mailing list