Say I have a JSON string and it has an error and thus can not be parsed. Then I want to parse another JSON string, which will replace the original one. I want to do that using the same rapidjson::Document
as eventually I need to have parsed the valid JSON in that document.
So:
rapidjson::Document document;
if (document.Parse<0>("{ \"hello\" : \"wor........ ").HasParseError())
{
// How to parse the correct json "{ \"hello\" : \"world\" }" here
// using the same `Document` ?
}
Should I just write
if (document.Parse<0>("{ \"hello\" : \"wor........ ").HasParseError())
{
document.Parse<0>("{ \"hello\" : \"world\" }");
}
Yes, if first parsing hes error then parsing another JSON by using the same document
is OK, as far as it clears that data and parses newly.