C ++: Wie erstelle ich ein Array mit boost :: property_tree?

Ich sehe keine Möglichkeit, ein Array mit dem Eigenschaftsbaum boost :: zu erstellen. Der folgende Code ...

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>

#include <iostream>

int main()
{
  try {
    boost::property_tree::ptree props;
    props.push_back(std::make_pair("foo", "bar"));
    props.push_back(std::make_pair("foo", "baz"));
    boost::property_tree::write_json("prob.json", props);
  } catch (const std::exception & ex) {
    std::cout << ex.what() << std::endl;
  }
}

... gibt mir nur ...

{
  "foo": "bar",
  "foo": "baz"
}

Die Dokumente zu boost :: property_tree sind spärlich. Wie erstelle ich ein JSON-Array mit boost :: property_tree?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage