C++: How to create an array using boost::property_tree?

前端 未结 1 1147
孤城傲影
孤城傲影 2020-12-30 05:02

I don\'t see a way to create an array using boost::property tree. The following code ...

#include 
#include 

        
相关标签:
1条回答
  • 2020-12-30 05:14

    If you have a sub-tree whose only nodes have empty keys, then it will be serialized as an array:

    boost::property_tree::ptree array;
    array.push_back(std::make_pair("", "bar"));
    array.push_back(std::make_pair("", "baz"));
    
    boost::property_tree::ptree props;
    props.push_back(std::make_pair("array", array));
    
    boost::property_tree::write_json("prob.json", props);
    
    0 讨论(0)
提交回复
热议问题