brianmario/yajl-ruby

ParserError on number with leading 0

Closed this issue · 1 comments

I don't know if this is a problem with yajl-ruby, yajl, or the json document I'm seeking to parse.

The following json

....
{
  "annotationtext" : 01773,
  "annotationtitle" : "GeogCode"
}
....

gives:

JSON::ParserError: parse error: after key and value, inside map, I expect ',' or '}'
                "annotationtext" : 01773,                      "an
                 (right here) ------^

from /Library/Ruby/Gems/1.8/gems/yajl-ruby-0.8.3/lib/yajl/json_gem/parsing.rb:16:in `parse'
from (irb):17

Although the parser will accept the number without a leading 0 (or when it's in quotes).

I'm using "ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]" on OSX 10.6.8.

And thanks for this gem btw, it should make dealing with 100Mb json files much easier!

Ah, looks like rfc4627 prohibits leading zeros. I'll go back to the author of the json document!