JSON parser grammar
dean at deanlandolt.com
Tue Jun 22 19:07:10 PDT 2010
On Tue, Jun 22, 2010 at 9:34 PM, Oliver Hunt <oliver at apple.com> wrote:
> On Jun 22, 2010, at 6:06 PM, Douglas Crockford wrote:
> > On 6/22/2010 5:28 PM, Garrett Smith wrote:
> >> Most of the questions on Grammar were answered in this thread,
> >> however, the question of U+0009 as a JSONStringCharacter remains. All
> >> major browsers allowi U+0009 in JSONString. What should the capability
> >> test check? If all major browsers parse without error ' "\t" ' to
> >> result in a string with the character U+0009, then the feature test
> >> can detect that failing and use the fallback.
> >> JSON.parse accepting U+0009 in strings is now part of public API and
> >> major libraries rely on that. Is going to be codified?
> >> To summarize, the pressing questions are:
> >> 1) Is the spec going to change to allow U+0009? And if it isn't, why
> not? and
> >> 2) What should the fallback for JSON.parse use? Should it:
> >> (a) go by the letter of the spec and perform a capability test to
> >> expect that an error is thrown for JSON.parse(' "\t" '), or
> >> (b) go with what seems to be a de facto standard and allow U+0009 as
> >> JSONStringCharacter?
> > This has already been asked and answered. We are going with a strict
> interpretation of the JSON standard.
> I believe that implication is that the strict JSON spec should be changed.
> Currently all implementations of "JSON" are incorrect in the respect, which
> to me implies that the spec is wrong.
But that's the rub -- the JSON spec cannot be changed. It (intentionally)
has no version number. ECMA could superset it -- ES-JSON, if you will --
which could specifically allow \t, but this could not strictly be considered
JSON, and would break in many JSON parsers in the wild.
Perhaps there's value in ECMA taking on such a task (they're in a unique
position to get real traction behind a superset of JSON, and we all have a
wishlist of JSON extensions). But it certainly wouldn't be JSON.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss