jsmn icon indicating copy to clipboard operation
jsmn copied to clipboard

Empty array element parsing

Open zserge opened this issue 9 years ago • 2 comments

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.


  • Bitbucket: https://bitbucket.org/zserge/jsmn/issue/41
  • Originally reported by: Anonymous
  • Originally created at: 2014-12-02T16:00:40.825

zserge avatar Oct 05 '15 14:10 zserge

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 avatar Oct 17 '15 13:10 zserge

Related to #52

zserge avatar Oct 17 '15 14:10 zserge