JSON parser grammar

View: New views
1 Messages — Rating Filter:   Alert me  

JSON parser grammar

by Oliver Hunt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So i've been looking at the JSON object grammar and have been talking  
to brendan and i'm getting somewhat conflicting information.

The grammars on json.org and in the ES5 spec both prohibit leading 0's  
on any number, but the various implementations disagree with this.

json2.js (from json.org), ie8, and chrome all support the standard ES  
octal literal lexer -- eg. JSON.parse("[010]")[0] === 8

SpiderMonkey allows a leading 0 but still interprets it as a decimal  
value -- eg. JSON.parse("[010]")[0] === 10

It seems to me that the spec needs to be corrected to specify what the  
behaviour actually is, rather than what we wish it could be.

--Oliver

_______________________________________________
es-discuss mailing list
es-discuss@...
https://mail.mozilla.org/listinfo/es-discuss