Opened 10 years ago

Closed 8 years ago

#7088 closed Bugs (invalid)

Error with property_tree

Reported by: dix75@… Owned by: Sebastian Redl
Milestone: To Be Determined Component: property_tree
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc:

Description

json {

cool : hp

}

I have Simple example: typedef boost::property_tree::basic_ptree< string_t, string_t > ptree; boost::property_tree::json_parser::read_json("path_out", pt); ptree pt;

auto result = pt.get_child(_T("cool")); result.add(_T(" "), _T("33333"));

std::for_each(result.begin(), result.end(), [&](ptree::value_type const& val) {

std::wcout << val.first << _T(" ") << val.second.data() << std::endl;

});

pt.put_child(_T("cool"), result); boost::property_tree::json_parser::write_json("path_out", pt);

i have:

json {

cool :

{

"": "hp", " ": "33333"

}

}

Why. I need array

Change History (2)

comment:1 by viboes, 10 years ago

Component: Noneproperty_tree
Owner: set to Sebastian Redl

comment:2 by Sebastian Redl, 8 years ago

Resolution: invalid
Status: newclosed

All keys must be empty for the node to be treated as an array. In your case, your key is a single space.

Note: See TracTickets for help on using tickets.