JSONCPP使用

Json是一种数据传输协议,规定了数据格式。

{"key":"value","key1":"value1"}


读取Json字符串(include <json.h>

	Json::Value value;
	Json::Reader reader;
	Json::Value::iterator iter;
	Json::Value::Members members;
	bool parsingSuccessful = reader.parse( json_str, value );
	if (parsingSuccessful) {
	  members = value.getMemberNames();
	  for (Json::Value::Members::iterator it = members.begin();
	    it != members.end(); ++it) {
	    std::string name = *it;
	    std::string value_str = value[name].asString();
	    cout<<name<<":"<<value_str<<endl;
	  }
	}



 

posted @ 2012-07-31 11:01  春文秋武  阅读(145)  评论(0编辑  收藏  举报