JSON parser grammar
Allen.Wirfs-Brock at microsoft.com
Wed Jun 23 08:15:52 PDT 2010
> -----Original Message-----
> From: es-discuss-bounces at mozilla.org [mailto:es-discuss-
> I am not suggesting that browser should not escape tabs, the issue is whether a
> conforming JSON implementation is allowed to parse a string that includes tab
This issue was explicitly discussed and decided within TC39 while drafting and reviewing the ES5 specification. The final decisions is reflected in the final normative paragraph of 15.12.2 (Jason.parse):
"It is not permitted for a conforming implementation of JSON.parse to extend the JSON grammars. If an implementation wishes to support a modified or extended JSON interchange format it must do so by defining a different parse function."
Given the general tolerance of implementation specific extensions within the ECMAScript specification, this was not just a casual decision. The decision was made with the knowledge that many existing JSON parsers supported an extended grammar. To the extent that the spec. differ from any implementation that predate it, that is intentional and the expectation is that those implementation would need to change to be in conformance.
Nothing in the spec. says that an conforming JSON implemented is not allowed to parse a string that includes (unescaped) tab characters. It just says that the function that does so may not be named JSON.parse. If you want to provide in your conforming implementation support for parsing an extended form of the JSON grammar, feel free. Just call it JSON. parsePostel or anything else other than JSON.parse.
More information about the es-discuss