« Return to Thread: JSON parser grammar
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.
A JSON parser transforms a JSON text into another representation. AI think the behavior you state of json2.js, ie8, and chrome should be considered a bug. I hesitate to make the same statement about SpiderMonkey, because their behavior falls within both the letter and spirit of the rfc, while maintaining the subset relationship between JSON and EcmaScript.
JSON parser MUST accept all texts that conform to the JSON grammar.
A JSON parser MAY accept non-JSON forms or extensions.
« Return to Thread: JSON parser grammar
| Free embeddable forum powered by Nabble | Forum Help |