JSON text is not a subset of PrimaryExpression

Richard Gibson richard.gibson at gmail.com
Tue Jul 25 16:45:14 UTC 2017


https://github.com/gibson042/ecma262-proposal-json-superset

On Wed, Jul 19, 2017 at 12:36 AM, Mark S. Miller <erights at google.com> wrote:

> I argued for that in the old es3.1 days. IIRC so did Mike Samuel and
> Crock. The pain of doing it now would be higher than it would have been
> then. Nevertheless, I would still be in favor.
>
> Please draft a proposal. Thanks.
>
>
> On Jul 18, 2017 8:16 PM, "Richard Gibson" <richard.gibson at gmail.com>
> wrote:
>
> Another relevant option: Feature Request: Make ECMA262 a superset of JSON
> <https://esdiscuss.org/topic/feature-request-make-ecma262-a-superset-of-json#content-8>
>
> On Tue, Jul 11, 2017 at 9:33 AM, Mike Samuel <mikesamuel at gmail.com> wrote:
>
>> https://tc39.github.io/ecma262/#sec-json.parse says
>>
>> """
>> NOTE
>>
>> Valid JSON text is a subset of the ECMAScript PrimaryExpression syntax
>> as modified by Step 4 above. Step 2 verifies that JText conforms to
>> that subset, and step 6 verifies that that parsing and evaluation
>> returns a value of an appropriate type.
>> """
>>
>> IIUC, if JSON text where a subset of PrimaryExpression then there
>> should be no string that parses via JSON.parse which does not eval
>> when wrapped in parentheses.
>> On recent (Chrome, Safari, Firefox),
>>
>>     var s = String.fromCharCode(0x22, 0x2028, 0x22)
>>     JSON.parse(s);   // Passes
>>     eval('(' + s + ')');  // raises SyntaxError
>>
>> I believe the only reason it's not a subset is that both exclude line
>> terminators from quoted string bodies but JSON does not treat U+2028
>> and U+2029 as line terminator chars while EcmaScript does.
>>
>> Could we change "is a subset of" to "is almost a subset of" or "is a
>> subset (modulo LineTerminators) of"?
>>
>>
>> Some related discussion at
>> https://esdiscuss.org/topic/json-response-to-statement-from-w3c-tag
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170725/ef23271e/attachment.html>


More information about the es-discuss mailing list