1. Serge Zaitsev
  2. jsmn
  3. Issues
Issue #21 resolved

Specify string input length

Patrik Lindegren
created an issue

The parse method: jsmn_parse(jsmn_parser parser, const char js, jsmntok_t *tokens, unsigned int num_tokens)

only handles parsing of null terminated strings. This is unfortunate since a common use case is to read the json from file, where the string is not null terminated. To work around this I currently need to read the file into a buffer larger than the file and then zero terminate it. The other alternative is to make a copy of the entire json string once the file has been loaded.

This would easily be solved if I could specify the length of the string when parsing.

Thanks Patrik