JSON parser grammar

Oliver Hunt oliver at apple.com
Wed Jun 3 11:25:03 PDT 2009


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



More information about the es-discuss mailing list