decimals without integer part in JSON source text (was: Re: JSON parser grammar)

Mark S. Miller erights at
Tue Aug 25 12:57:11 PDT 2009

On Tue, Aug 25, 2009 at 9:32 AM, Hallvord R. M. Steen <hallvord at>wrote:

> This apparently makes numbers like "1." illegal?
> [...]
> I suggest that the spec is changed. [...]
> I suggest this change because the browser implementations seem to align on
> allowing this.

While the JSON spec itself allows parsers to accept strings outside the
standard JSON grammar, the ES5 spec for the JSON object was carefully
constructed to give us a validating parser: one that rejects non-JSON text.
I would like to preserve this property, as it is what justified the need for
adding a new JSON primitive to JavaScript.

Without a new primitive, the best that JS code has been able to do
efficiently is json2.js and json_sans_eval.js. The first being too dangerous
as it guards an eval with delicate complex regular expressions no one
understands. The second is about as fast but is non-validating. If a safe
efficient non-validating parser were adequate we wouldn't need a new

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list