JSON parser grammar
Mark S. Miller
erights at google.com
Thu Jun 4 07:27:53 PDT 2009
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.
More information about the es5-discuss