标签:jsoncpp
#include "/home/lhy/my_json/include/json/json.h"
#include <string.h>
#include <iostream>
using namespace std;
class JSON
{
public:
void To_str(string &_s,Json::Value &value)
{
Json::StyledWriter _write;
_s = _write.write(value);
}
void To_vlu(string &_s,Json::Value & value)
{
Json::Reader _read;
_read.parse(_s,value,false);
}
};
int main()
{
Json :: Value v;
JSON my_json;
v["1"]="c++";
v["2"]="c";
v["3"]="linux";
v["4"]="windows";
string s;
my_json.To_str(s,v);
cout<<s.c_str()<<endl;
Json :: Value w;
my_json.To_vlu(s,w);
Json :: Value :: iterator it = w.begin();
cout<<w["1"].asString().c_str()<<endl;
cout<<w["2"].asString().c_str()<<endl;
cout<<w["3"].asString().c_str()<<endl;
cout<<w["4"].asString().c_str()<<endl;
return 0;
}
g++ main.cpp -I /home/lhy/my_json/include/ /home/lhy/my_json/libjson_linux-gcc-4.4.7_libmt.a
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:jsoncpp
原文地址:http://blog.csdn.net/liuhuiyan_2014/article/details/47435347