JSON parser grammar

Erik Arvidsson erik.arvidsson at gmail.com
Wed Jun 3 12:11:01 PDT 2009


The V8 implementation is a pretty early implementation and I would
consider all of the issues raised here to be bugs in it.

V8 actually just compiles the json as ordinary js:

http://www.google.com/codesearch/p?hl=en#W9JxUuHYyMg/trunk/src/json-delay.js&q=ParseJSONUnfiltered&l=30

I'm CCing Christian Plesner Hansen who wrote the JSON.parse method for
V8 as well as v8-users.

On Wed, Jun 3, 2009 at 11:25, Oliver Hunt <oliver at apple.com> wrote:
>
> On Jun 3, 2009, at 11:18 AM, Rob Sayre wrote:
>
>> On 6/3/09 2:12 PM, Oliver Hunt wrote:
>>>>
>>>> 1.) leading zeros are parsed as decimal numbers (octal seems like a bug
>>>> no matter what, per MarkM)
>>>
>>> IE8 and V8's JSON implementation, and json2.js at json.org all interpret
>>> 010, as octal (eg. 8), and 009 as 9
>>
>> Yes, I understand. Do you see why strict mode makes this behavior
>> undesirable?
>
> I'm not saying it makes the behaviour desirable, i'm commenting on the fact
> that any time implementations have been lax eventually all implementations
> become lax.  I for one welcome our octal-free overlords ;)
>
>>>> 2.) trailing commas in objects and arrays are allowed
>>>> ({"foo":42,"bar":42,})
>>>
>>> V8's JSON implementation also accepts [1,,,2]
>>
>> What does it produce? An array with holes, or an array with null members?
>
> An array with holes -- in so far as i can tell V8's json object exactly
> matches the result of eval(string), just prohibiting arbitrary code
> execution.
>
>> - Rob
>
> --Oliver
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
erik


More information about the es-discuss mailing list