-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a JSMN_SINGLE option to parse one object at a time
Previously, jsmn parsed all input provided, parsing multiple objects if present. If the last object is incomplete, it would return JSMN_ERROR_PART, even if there was at least one complete object before it. This makes it difficult to parse streams of objects: The input reader must ensure the input buffer ends on an object boundary. The JSMN_SINGLE macro provides a solution to this by configuring jsmn to parse objects one at a time. As soon as a complete object is parsed, jsmn returns, ignoring the rest of the input. The parser state will be reinitialized, so to parse the next object, simply advance the input buffer pointer ahead by tokens[0].end characters and call jsmn_parse() again.
- Loading branch information
1 parent
ba073ee
commit 5d1d04e
Showing
2 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters