C++ 增强c++;属性映射-将数组转换为向量

C++ 增强c++;属性映射-将数组转换为向量,c++,json,boot,C++,Json,Boot,如何使用从json解码的boos属性映射将数组从stl转换为向量 hash = {'time_series':[1.0,1.0]) ptree pt2; std::istringstream is (content); read_json (is, pt2); std::vector<double> time_series = pt2.get("time_series"); ../sr

如何使用从json解码的boos属性映射将数组从stl转换为向量

               hash = {'time_series':[1.0,1.0])


                ptree pt2;
        std::istringstream is (content); read_json (is, pt2);
        std::vector<double> time_series = pt2.get("time_series");

../src/rtbTimeSeries.cpp:172:62: error: no matching function for call to ‘boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::get(const char [12])’
hash={'time_series':[1.0,1.0])
ptreept2;
istringstream是(内容);read_json(是,pt2);
std::vector time_series=pt2.get(“time_series”);
../src/rtbTimeSeries.cpp:172:62:错误:调用“boost::property_tree::basic_ptree::get(const char[12])时没有匹配的函数

您应该使用这样的东西

std::vector<double> v;
pt::ptree subtree = p.get_child("time_series");
for (const auto& tree : subtree)
{
  v.push_back(tree.second.get<int>(""));
}
for (auto i : v)
{
   std::cout << i << std::endl;
}
std::vector v;
pt::ptree子树=p.get_child(“时间序列”);
for(常量自动&树:子树)
{
v、 向后推(tree.second.get(“”);
}
用于(自动i:v)
{

std::cout您的错误首先出现,因为您没有为
get
函数指定模板类型。请参阅以了解如何读取数组

我认为没有一种简单的方法可以作为一个容器来阅读,但是它似乎有可能得到。它可能与vector的构造函数一起使用