把键值对中的值转成string类型
注意asString后类型是Json::String并不是std::string
Json::Value rootJsonValue; rootJsonValue["foo"] = "bar"; std::string s = rootJsonValue["foo"].asString(); std::cout << s << std::endl; // bar
把整个Json::Value转成string
std::string JsonAsString(const Json::Value &json) { std::string result; Json::StreamWriterBuilder wbuilder;
wbuilder["indentation"] = ""; // Optional result = Json::writeString(wbuilder, json); return result; }