json数组如下:
{"var_name":"var1","positions":[0.1,0.1,0.1,0.1,0.1,0.1]},;
1
代码:
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
std::stringstream str_stream(json_content);
boost::property_tree::ptree root;
boost::property_tree::read_json(str_stream, root);
// get_child得到数组对象
boost::property_tree::ptree positions_array = root.get_child("positions");
boost::property_tree::ptree::iterator pos = positions_array.begin();
for(; pos != positions_array.end(); ++pos)
{
double value = pos->second.get_value<double>();
std::cout<<"value "<<job <<std::endl;
}
————————————————
版权声明:本文为CSDN博主「itfanr」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/itfanr/article/details/82995489