测试配置代码:test_json.cpp
#include<iostream>
#include<jsoncpp/json/json.h>
//g++ -o testjson test_json.cpp -ljsoncpp
using namespace std;
int main()
{
string test="{\"id\":0,\"name\":\"sikui\"}";//每个key用\"key\"表示,value用:value表示
Json::Reader reader;
Json::Value value;
if(reader.parse(test,value))
{
if(!value["id"].isNull())
{
cout<<value["id"].asInt()<<endl;
cout<<value["name"].asString()<<endl;
}
}
return 0;
}
linux环境下开源库jsoncpp使用教程
C++解析JSON进行网络传输--一个通过JSON方式的socket传输
Linux下通过jsoncpp和socket解析和发送json数据的使用例程
https://blog.csdn.net/hxlawf/article/details/103136538