3 ms·
I started out using JSMN for parsing JSON in our embedded devices at work, but the requirement to pre-allocate all the tokens turned out to be a problem - I was
by m_eiman 9y ago
I started out using JSMN for parsing JSON in our embedded devices at work, but the requirement to pre-allocate all the tokens turned out to be a problem - I was running out of memory when the configuration files got too large…
So I wrote a new parser that trades lower RAM usage for higher CPU usage: https://bitbucket.org/tlabwest/json-reader/overview https://bitbucket.org/tlabwest/json-reader/overview
Sample usage:
json_token_t json;
json_validate(json_string, &json);
json_token_t value;
json_find(&json, "key1/subkey:2/value1", &value);
char s[bufsize];
json_decode_string(&value, s, bufsize);
printf("%s\n", s);
json_free(&json);