JSON parser grammar
douglas at crockford.com
Wed Jun 3 12:21:52 PDT 2009
Allen Wirfs-Brock wrote:
>> should be an error, per spec. Nobody follows the spec though...
> As I read them neither the RFC or the current ES5 JSON grammar recognize "" as a valid JSON form, so according to the ES5 spec. a syntax error should be thrown. If we really want all implementation to accept "010" as a JSONNumber then we should specify it as such. Of course we have to define what it means (decimal, octal??).
> My inclination would be to require ES5 implementation to exactly conform the whatever JSON grammar we provide and to throw syntax errors if the input doesn't exactly conform to the grammar. (in other say that the section 16 extension allowance doesn't apply to JSON.parse. If an implementation wants to support JSON syntax extensions it could always do so by providing a JSON.parseExtended function (or whatever they want to call it) that uses an implementation defined grammar.
I agree. It is not helpful to developers to allow weird forms on browser A but
not on browser B. What should be allowed is clearly described in the E5 spec.
More information about the es-discuss