zserge / jsmn

Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket
MIT License
3.65k stars 778 forks source link

Empty array element parsing #41

Open zserge opened 8 years ago

zserge commented 8 years ago

I found out that parsing the string "[a,,b]" produces an array with 2 elements, while a browser interprets it as a 3-element array, where the second is undefined. I don't know if you will find this useful, but i wrote a patch to parse the empty second array element as an empty string.


zserge commented 8 years ago

Parsing such array as 3 elements is definitely incorrect, in browser as well:

JSON.parse('[1,,3]')
SyntaxError: JSON.parse: unexpected character at line 1 column 4 of the JSON data

The fact that it works in strict mode is a bug.

zserge commented 8 years ago

Related to #52