Q:

Boost c++ and property map - getting an array into a vector

How do I get an array into a vector from stl from using boos property map decoded from json
               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])’

A:

You should use something like this
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;
}

http://liveworkspace.org/code/WlrPt$16

