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.
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
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.