JSON parser grammar

Robert Sayre sayrer at gmail.com
Tue Jun 2 22:32:31 PDT 2009


On Wed, Jun 3, 2009 at 1:27 AM, Allen Wirfs-Brock
<Allen.Wirfs-Brock at microsoft.com> wrote:
>
> The intent was for the ES5 JSON grammar to exactly match the JSON RFC grammar.  If you think it is different, then you may have found a bug so let's make sure...

It definitely doesn't match, on purpose. For example, the RFC requires
JSON strings to represent objects (or arrays) at the root, no
primitives allowed.

>
> Examples, please? The intent is that applying JSON.parse to a string containing a valid JSON form should produce an equivalent set of objects on all conforming ES5 implementation.

JSON.parse("[010]")

should be an error, per spec. Nobody follows the spec though...


-- 

Robert Sayre

"I would have written a shorter letter, but I did not have the time."


More information about the es-discuss mailing list