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

Oliver Hunt oliver at
Tue Aug 25 13:09:54 PDT 2009

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

> On Sat, 04 Jul 2009 13:49:01 +0200, Hallvord R. M. Steen
> <hallvord at> wrote:
>> Another question: The JSON grammar says
>> JSONNumber ::
>> -opt  DecimalIntegerLiteral JSONFraction opt  ExponentPart opt
>> JSONFraction ::
>> . DecimalDigits
>> This apparently makes numbers like "1." illegal?
> I suggest that the spec is changed. In under "Syntax", add
> "JSONFraction" on a new line after
> JSONNumber ::
> 	-opt  DecimalIntegerLiteral JSONFractionopt  ExponentPartopt
> in other words, define JSONNumber as follows:
> JSONNumber ::
> 	-opt  DecimalIntegerLiteral JSONFractionopt  ExponentPartopt
> 	JSONFraction
> I suggest this change because the browser implementations seem to  
> align on
> allowing this.

The WebKit JSON parser does not allow this (You can test in Safari  
4.0.3 or a nightly build) -- In general the JSON parser in WebKit is  
strictly conformant with the spec (i am unaware of anywhere the parser  
breaks conformance to the strict grammar and lexer of the spec -- if  
someone finds one i consider it a bug and encourage them to file at 
  :D ).  We also haven't received any bugs relating to compatibility  
of a strict parser/lexer vs. eval-driven parsing.


More information about the es-discuss mailing list