创建JSON数组:

boost::property_tree::ptree array;

array.push_back(std::make_pair("", "element0"));

array.push_back(std::make_pair("", "element1"));

boost::property_tree::ptree props;

props.push_back(std::make_pair("array", array));

boost::property_tree::write_json("prob.json", props);

遍历数组:

BOOST_FOREACH(const boost::property_tree::ptree::value_type &v, array)

 {

    // v.first is the name of the child.

    // v.second is the child tree.

}

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐