zserge / jsmn

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

Changed child counting to skip-lists. #98

Open frobnitzem opened 7 years ago

frobnitzem commented 7 years ago

This change preserves the size of the jsmntok_t structure, adds lots of comments, passes nearly* all the tests, and even slightly reduces the total code size. It also adds description about what happens in a partial parse.

Unfortunately, unquoted keys in objects doesn't work because I test the parent type whenever ':' is encountered -- so test_unquoted_keys fails. A better way to fix this would be to add a parser state to remember what we're looking for next.

It holds the following tokens:

JSMN builds meta-tokens that point to token boundaries in the JSON string and list their types and relationships. In the example above jsmn will create tokens like: Object [0..31] (skip 5), String [3..7] (skip 2), String [12..16] (skip 1), String [20..23] (skip 2), Number [27..29] (skip 1).

littleyoda commented 6 years ago

Hi

I tested your changes with the following json, but I received a JSMN_ERROR_INVAL.

{"version":"3", "cfg":[{"m":"ap"},{"m":"xx"}]}

Without your changes, this json is parsable.