#define _CRT_SECURE_NO_WARNINGS #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> #include <boost/foreach.hpp> #include<opencv2/opencv.hpp> #include<vector> #include <sstream> using namespace std; using namespace cv; using namespace boost::property_tree; int main() { string str_json = "{\"ret\":\"http://ovuhjq3qc.bkt.clouddn.com/2017-11-1617:20:22-920-.png\",\"error\":\"errortype\"}"; ptree pt; //define property_tree object stringstream ss(str_json); //字符串流stringstream,把string类型转换为stringstream try { read_json(ss, pt); //reson_json函数将文件流、字符串解析到ptree } catch (ptree_error & e) { return 1; } string str = pt.get<std::string>("ret"); //获取到json数据的key的值value cout << str << endl; st
cgi+json
最新推荐文章于 2021-11-22 21:27:08 发布
本文示例展示了如何使用Boost库解析和生成JSON数据,同时讲解了CGI程序如何通过环境变量获取客户端数据。代码中包含了JSON字符串的读取、点集数据的构造和序列化为JSON格式,以及CGI接口中QUERY_STRING的处理。
摘要由CSDN通过智能技术生成