我看不到使用 boost::property 树创建数组的方法。以下代码...
#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;
}
}
...只是给我...
{
"foo": "bar",
"foo": "baz"
}
boost::property_tree 上的文档很少。如何使用 boost::property_tree 创建 JSON 数组?