如何使用boost::property_tree表示JSON数组

创建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.

}

你可能感兴趣的:(如何使用boost::property_tree表示JSON数组)