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

Oliver Hunt oliver at apple.com
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 opera.com> 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 15.12.1.1 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 http://bugs.webkit.org 
  :D ).  We also haven't received any bugs relating to compatibility  
of a strict parser/lexer vs. eval-driven parsing.

--Oliver



More information about the es-discuss mailing list