标签:string html include 开源库 示例 iostream doc filename end
jsoncpp
是一个用于操作json
数据的C++开源库
代码地址:https://github.com/open-source-parsers/jsoncpp
使用文档:http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
使用过程中遇到一个错误,这里作为记录
error C4996: ‘Json::Reader‘: Use CharReader and CharReaderBuilder instead
error C4996: ‘Json::Reader::Reader‘: Use CharReader and CharReaderBuilder instead
Json::CharReaderBuilder readerBuild;
Json::CharReader* reader(readerBuild.newCharReader());
#include <iostream>
#include "json/json.h"
int main()
{
std::cout << "Hello world" << std::endl;
const char* strValue = "{\"file_path\": \"./test_models/test.obj\", \"filename\":\"test.obj\", \"code_id\": 3 }";
Json::CharReaderBuilder readerBuild;
Json::CharReader* jsonReader(readerBuild.newCharReader());
Json::Value jsonValue;
JSONCPP_STRING jsonErrs;
bool isParse = jsonReader->parse(strValue, strValue + std::strlen(strValue), &jsonValue, &jsonErrs);
if (isParse && 0 == jsonErrs.size()){
std::string filePath = jsonValue["file_path"].asString();
std::string fileName = jsonValue["filename"].asString();
int codeId = jsonValue["code_id"].asInt();
std::cout << "filePath: " << filePath << " fileName: " << fileName << " codeId: " << codeId << std::endl;
}
return 0;
}
标签:string html include 开源库 示例 iostream doc filename end
原文地址:https://www.cnblogs.com/xiaxuexiaoab/p/14574884.html