更多方法参考:https://abraverman.gitee.io/2020/05/12/json-cpp/
//json_value.cpp文件 //原有的 String Value::toStyledString() const { StreamWriterBuilder builder; builder["emitUTF8"] = true; //新添加的-输出中文 而非unicode String out = this->hasComment(commentBefore) ? "\n" : ""; out += Json::writeString(builder, *this); out += '\n'; return out; } //新添加 Json::String Value::toRawString() const { StreamWriterBuilder builder; builder["commentStyle"] = "None"; builder["indentation"] = ""; builder["emitUTF8"] = true; String out = Json::writeString(builder, *this); return out; } bool Value::parse(std::string_view str) { Json::CharReaderBuilder builder; const std::unique_ptr reader(builder.newCharReader()); Json::Value root; std::string err; return reader->parse(str.data(), str.data()+str.size(),this,&err); }
0