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; } }