jsmn icon indicating copy to clipboard operation
jsmn copied to clipboard

JSON validation escapes with JSMN_STRICT

Open zserge opened this issue 9 years ago • 3 comments

When using JSMN_STRICT, some cases of invalid JSON are not caught. The following JSON's are parsed as valid.

{"a"}

{"a":1,"b"}

{"a","b":1}

{"a":1,}

{"a":"b":"c"}

{,} (any number of ",")

There may be more examples.


  • Bitbucket: https://bitbucket.org/zserge/jsmn/issue/52
  • Originally reported by: matthewb_gc
  • Originally created at: 2015-07-22T14:31:42.617

zserge avatar Oct 05 '15 14:10 zserge

Hello Serge,

Have you had a chance to investigate this issue? Should I re-open this issue in the new github repo?

Thank you


Original comment by: matthewb_gc

zserge avatar Oct 05 '15 14:10 zserge

I suspect the best way to handle this is a simple state machine built in to the parser.

DemiMarie avatar Sep 30 '16 13:09 DemiMarie

According to this answer http://stackoverflow.com/a/22361229/6742459 the first one {"a"} is valid for RFC-7159 but invalid for RFC-4627.

zlolik avatar Oct 03 '16 19:10 zlolik