【c++】rapidjson實踐

rapidjson以其高效獲得很大的使用,在自己的使用中,遇到了一些不知所措的錯誤,在實踐中把自己遇到的問題記錄下來,爲大家解決問題方便。
1.解析string到document

std::string str("{}");
RAPIDJSON_NAMESPACE::Document document;
document.Parse(str.c_str());

if (document.HasParseError())
{
    RAPIDJSON_NAMESPACE::ParseErrorCode errCode = document.GetParseError();
}

2.設置Int到document

RAPIDJSON_NAMESPACE::Document document;
document.Parse("{}");
document.AddMember("R", 0, allocator);

是不是很簡單?如果不Parse一次再填寫值,就會報Assert(),IsObject()問題。

待續。。。。。。。

發佈了114 篇原創文章 · 獲贊 52 · 訪問量 60萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章