我需要使用Boost库在C ++中创建一个JSON对象
这有效
boost::property_tree::ptree root;
boost::property_tree::ptree children;
boost::property_tree::ptree child;
child.put("test", "value");
children.push_back(std::make_pair("", child));
root.add_child("elms", children);
但是,如果children
为空,则elms
属性在JSON对象中为空字符串。如果elms
,如何将children
属性设置为空数组是空的吗?
boost::property_tree::ptree root;
boost::property_tree::ptree children;
// "elms" is set as an empty string?
root.add_child("elms", children);