3 ms·
For json parsing, I really like JSMN (https://github.com/zserge/jsmn/ https://github.com/zserge/jsmn/). It doesn't allocate memory, has a simple and easy to use
by duozerk 9y ago
For json parsing, I really like JSMN (https://github.com/zserge/jsmn/ https://github.com/zserge/jsmn/). It doesn't allocate memory, has a simple and easy to use API, and is pretty fast.
- m_eiman 9y agoI 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);
- Asmod4n 9y agoIts sadly not strict enough what it accepts, got a buffer overflow quite easily. So you probably shouldn't use it for user supplied data.
- ythn 9y agoIn terms of pure syntactic sugar/ease of use, it's hard to beat nlohmann/json: https://github.com/nlohmann/json https://github.com/nlohmann/json It may not be as fast as these other guys but it's sure as heck a lot more intuitive and convenient. For casual JSON usage cases, I've been recommending this library.