-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to parse json by parts #527
Comments
I think this is similar to FAQ about Reader/Writer (SAX):
|
At one time, I wanted to be able to start parsing a string that contains a partial input (because the full input may not yet be available) and later continue parsing on more strings with remaining parts of the input. It sounds like the same thing that @AlexeySagin is requesting. @miloyip I don't understand the question/answer in the FAQ and its connection to this issue. When I read “pause the parsing,” it sounds like an active choice I make to stop parsing, whereas I don't want to stop parsing but rather parsing should continue until it runs out of input, and I should be able to continue parsing with new input. I believe this could be hacked together with RapidJSON as it is, but I never tried. |
To parse a JSON in multiple parts, it is like:
Since currently the parser cannot resume its internal state (even iterative parser does not maintain internal states within single value), it will be quite impossible to change the code to support this. The workaround in FAQ: Thread A
Thread B
Of course this can be done with double buffering so both threads can be run in parallel. Note that some parsers like YAJL can do parsing part by part. The tradeoff is the unavoidable performance penalty. |
@miloyip Thanks. That makes more sense. |
Maybe an example using pthread can demonstrate this. |
I created an example using C++11 thread. But I am not familiar with it. |
The parser enhancement is required to parse json partially.
The following functionality of the lirary would be very helpful: the ability to send to the parser json request divided by separated parts as it is recieved from server/client/etc.
At the moment it has to wait until all the json parts are recieved and only then the complete json can be passed to the parser. It would be great if the parts can be passed to the parser separately.
The text was updated successfully, but these errors were encountered: