Open azim0ff opened 8 years ago
My implementation of skip-lists does something like this. Parsing your string, {"jsonrpc":"2.0","method":"echo","params":["hello", "world"],"id":1} creates 10 tokens: '{'(10) "jsonrpc"(2) "2.0"(1) "method"(2) "echo"(1) "params"(4) '['(3) "hello"(1) "world"(1) "id"(2) 1(1)
Skip instead of count means you can always jump directly the next sibling.
Hey, just wanted to share a small tweak to JSMN that I've been using to help with traversing the token tree. Following how things are done in JSMN_PARENT_LINKS, I've added JSMN_FIRST_CHILD_NEXT_SIBLING.
I use it to help with parsing jsonrpc requests. For example, if I have a json string like this:
{"jsonrpc":"2.0","method":"echo","params":["hello", "world"],"id":1}
... and want to get the value of "id", I iterate over the "first level" elements.
Would you be interested in this feature?