title: C++ boost property tree getting values
body: <p>I've been trying the past 2 days to find out how do I do the following thing in C++:</p>
  
  <p>I have a json string:</p>
  
  <pre><code>[
       {
         "pid" : 0,
         "nick":"Foo",
         "score":12,
         "ping":50
       },
       {
         "pid":1,
         "nick":"Bar",
         "score":23,
         "ping":24
       }
  ]
  </code></pre>
  
  <p>I want to iterate over all these childs and put, for example, PlayerID's values in a <code>std::vector</code> so that I can return all of them.</p>
  
  <p>Where I'm stuck is here:</p>
  
  <pre><code>// some code
  boost::property_tree::ptree pt;
  boost::property_tree::read_json(ss, pt);
  
  std::vector&lt;int&gt; players;
  int pid;
  BOOST_FOREACH(boost::property_tree::ptree::value_type &amp;v, pt.get_child("pid")) // I also tried with pt or pt.get_child("")
  {
      pid = v.second.data();
      players.push_back(pid);
  }
  return players;
  </code></pre>
  
  <p>I looked at the documentation but couldn't find anything good. Also, I've tried almost everything there and if it compiles without errors it'd give me what() expected object or something like that. I'm really stuck, any help is appreciated! Thanks in advance.</p>