JSON parser grammar

Mark S. Miller erights at google.com
Wed Jun 3 20:25:36 PDT 2009

On Wed, Jun 3, 2009 at 7:47 PM, David-Sarah Hopwood
<david-sarah at jacaranda.org> wrote:
> I am 100% in favour of tightly specifying what the ES5 JSON parser
> must accept, and what it must generate -- subject to the following
> caveat: [...]
> The constructs that must be accepted but not generated are:
>  - unescaped LineTerminators (at least <LS> and <PS>, possibly
>   also <CR> and <LF>) in string literals.

I thought the JSON grammar is already speced to treat <LS> and <PS> as
whitespace, not newlines, and so could be included in string literals.
(This has the unfortunate consequence that JSON is not a proper subset
of ES5, but we've already reluctantly decided to live with that.) I
see no reason why JSON should accept <CR> or <LF> in string literals.

>  - unquoted property names, matching <IdentifierName>, in
>   object literals.

Why? Had JSON been defined after ES5, no doubt it would have accepted
these. But that's spilled milk under the bridge on which the train has
already passed.


More information about the es5-discuss mailing list