C++ 解析json

来源:互联网 发布:微信红包显示网络出错 编辑:程序博客网 时间:2024/05/22 13:43
char str[MAX_PATH * 4] = {"{\"path\":\"http://192.168.2.21:8080/itsnew/holidays/getHolidaysList\",\"success\":true,\"type\":\"issued_type_update_data\",\"params\":{\"start\":317,\"limit\":1}}"};Json::Reader reader;Json::Value root;if (reader.parse(str, root)){// reader将Json字符串解析到root,root将包含Json里所有子元素int ret = root["success"].asBool();if (ret){string strPath=root["path"].asString();string strType=root["type"].asString();Json::Value val_image = root["params"];vector<string>vKeys = val_image.getMemberNames();vector<string>vValues;// 遍历数组for(int i = 0; i < vKeys.size(); ++i){string s = val_image[vKeys.at(i).c_str()].asString();vValues.push_back(s);}}}
http://download.csdn.net/detail/sz76211822/9621799
0 0
原创粉丝点击