Skip to content
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

Parser not serially reusable #34

Open
MitchBradley opened this issue Jan 9, 2024 · 0 comments
Open

Parser not serially reusable #34

MitchBradley opened this issue Jan 9, 2024 · 0 comments

Comments

@MitchBradley
Copy link

I have an asynchronous listener thread that receives JSON documents. After one is complete (endDocument is called), the next one is ignored because the parser is in STATE_DONE. I tried to do parser.reset() inside endDocument(), but that does not work because of this code

void JsonStreamingParser::endDocument() {
    myListener->endDocument();
    state = STATE_DONE;
  }

which sets STATE_DONE after endDocument, thus undoing the effect of parser.reset().

I have worked around the problem by setting a flag in endDocument and, when that flag is set, calling parser.reset() in the read loop.

It seems to me that it would be better to set STATE_DONE before calling endDocument(). I cannot think of any existing use that would break, considering that any existing code that calls parser.reset() would not work with the current order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant