【发布时间】:2014-05-13 14:40:36
【问题描述】:
假设我有一个 JSON 字符串,它有一个错误,因此无法解析。然后我想解析另一个 JSON 字符串,它将替换原来的字符串。我想使用相同的 rapidjson::Document 来做到这一点,因为最终我需要解析该文档中的有效 JSON。
所以:
rapidjson::Document document;
if (document.Parse<0>("{ \"hello\" : \"wor........ ").HasParseError())
{
// How to parse the correct json "{ \"hello\" : \"world\" }" here
// using the same `Document` ?
}
我应该写吗
if (document.Parse<0>("{ \"hello\" : \"wor........ ").HasParseError())
{
document.Parse<0>("{ \"hello\" : \"world\" }");
}
【问题讨论】: