JSON parser grammar

Douglas Crockford douglas at crockford.com
Thu Jun 4 10:18:47 PDT 2009

Mark S. Miller wrote:
> On Wed, Jun 3, 2009 at 9:48 PM, Allen Wirfs-Brock
> <Allen.Wirfs-Brock at microsoft.com> wrote:
>> Given that the output produced by stringify is specified algorithmically I don't see any reason to clutter the grammar with [not for output] annotations.  If we decide we want to quote <LS> or <PS> in outputted string literals we can specify such in the stringify Quote algorithm.
> Even at this late date, I think this change to the spec is called for.
> I agree we should change the Quote algorithm so that JSON.stringify
> does not generate unescaped <LS> or <PS> characters. JSON.parse would
> still accept them of course, and so the language accepted by
> JSON.parse (full JSON <value>) would not be a subset of ES5
> <expression>. But with this change, the subset of JSON <value> emitted
> by JSON.stringify would also be a subset of ES5 <expression>. Small
> cost with high payoff.

I disagree with your estimation of the payoff. And the escaping of \<LS> 
violates the JSON rules.

More information about the es5-discuss mailing list