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.
Strings: "name", "Jack", "age" (keys and some values)
Number: 27
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).
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:
{ "name" : "Jack", "age" : 27}
(the whole object)"name"
,"Jack"
,"age"
(keys and some values)27
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).