如何使用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.
}
新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。
更多推荐


所有评论(0)