Questions tagged [boost-propertytree]

The Boost PropertyTree library provides a data structure that stores an arbitrarily deeply nested tree of values, indexed at each level by some key. It serializes and emulates XML, JSON and INI file structures.

The Boost PropertyTree library provides a data structure that stores an arbitrarily deeply nested tree of values, indexed at each level by some key. It serializes and emulates XML, JSON and INI file structures.

Note: Boost.PropertyTree is not a generic XML parser. It is not intended to be used as a fast-and-dirty way to load arbitrary XML files into memory. It's XML serialization capabilities are for serialization. It is intended to read the XML that it has written.

Please stop using Boost.PropertyTree as a generic XML parser.

354 questions
15
votes
3 answers

Boost Property_Tree iterators, how to handle them?

I am sorry, I asked a question about the same topic before, but my problem concerns another aspect of the one described there (How to iterate a boost...). Take a look at the following code: #include #include #include…
Andry
  • 16,172
  • 27
  • 138
  • 246
15
votes
1 answer

How can I parse JSON arrays with C++ Boost?

I have a file containing some JSON content that looks like: { "frame": { "id": "0", "points": [ [ "0.883", "0.553", "0" ], [ "0.441", "0.889", "0" ], ] }, "frame": ... } How do I parse the values of the double…
user934801
  • 1,119
  • 1
  • 12
  • 30
13
votes
3 answers

c++: program settings - boost.PropertyTree or boost.program_options?

I was looking for a solution to store program settings or options or configuration in C++. These could be settings that are exposed in a GUI and need to be saved between runs of my code. In my search I came across boost.PropertyTree which seemed to…
User
  • 62,498
  • 72
  • 186
  • 247
12
votes
2 answers

Boost Property Tree with filename as key

I am trying to use filenames as the key in boost::PropertyTree However, the '.' character in a filename such as "example.txt" causes an additional layer to be added within the property tree. The most obvious solution would be to replace '.' with…
Andrew Hundt
  • 2,551
  • 2
  • 32
  • 64
11
votes
1 answer

Compilation error with boost::property_tree::xml_writer_settings

In order to pretty print my XML output with boost::property_tree, I wrote the following code: #include #include int main() { std::string filename = "test.xml"; …
Martin Delille
  • 11,360
  • 15
  • 65
  • 132
10
votes
1 answer

Parsing JSON with boost property tree

I'm building an application that gets movie information from themoviedb.com. The information is provided in a JSON file. I'm trying to store the information using boost property tree. But There is a little problem. I illustrate the problem by the…
Glenn Vonk
  • 103
  • 1
  • 1
  • 5
9
votes
5 answers

boost : Just iterate over elements of a ptree

This should be simple (I'm just learning boost so I'm missing something) I have read in some simple JSON using json_read and now have a ptree. All the examples on the web show using ptree.get("entry_name") to obtain an entry. All I want to do is…
Ross W
  • 1,300
  • 3
  • 14
  • 24
9
votes
1 answer

How to manually create a boost ptree with XML attributes?

I've been using boost libraries to parse XML files and I have to create a ptree manually. I need to add an XML attribute to the ptree. This is what the boost documentation suggests: ptree pt; pt.push_back(ptree::value_type("pi",…
Javier Buzano
  • 103
  • 1
  • 6
9
votes
3 answers

boost::property_tree::json_parser and two-byte wide characters

Introduction std::string text = "á"; "á" is two-byte character (assuming a UTF-8 encoding). So following line prints 2. std::cout << text.size() << "\n"; But std::cout still prints text correctly. std::cout << text << "\n"; My problem I pass…
Jarosław Gomułka
  • 4,935
  • 18
  • 24
8
votes
2 answers

Module properties name-value pair C++ API framework - reinvention?

I've often come across APIs that allow users to get and set various parameters that control a module's operation. I now find myself contemplating writing yet another properties API but don't want to reinvent the wheel. The following is typical…
paperjam
  • 8,321
  • 12
  • 53
  • 79
8
votes
3 answers

no end of line in boost property tree xml writer output

Consider the following code using boost::property_tree: #include #include using namespace boost::property_tree; int main() { ptree model_tree; model_tree.add("calibrated",…
gregory
  • 211
  • 2
  • 7
8
votes
1 answer

Boost read_json and C++11

I'm trying to parse JSON using Boost's property_tree parser and from C++11 code (my system is Debian Wheezy with gcc 4.7.2 and Boost 1.49). I tried the following code based on Serializing and deserializing json with boost: #include #include…
Daniel Kraft
  • 306
  • 3
  • 8
8
votes
2 answers

How can i get xml line number from ptree exception

I am using boost ptree to read an xml file like this: ptree myTree; ... /*open xml file*/ try{ myTree.get(s); } catch(boost::exception const& ex) { /*get useful info!*/ } I know I can use the what() function, but it produces an error…
yonigo
  • 987
  • 1
  • 15
  • 30
8
votes
1 answer

Checking if a value in a boost property tree is a tree or a terminal value

I have been looking for APIs in boost::property_tree (that is used for reading a json) that I can use to determine if a value of a field is a tree or a terminal value. For example, I have a json where the value of foo can either be a tree as…
rama44ster
  • 91
  • 1
  • 4
8
votes
1 answer

How to iterate over XML structure in boost::property_tree

I have an XML structure along the lines of:
Caribou
  • 2,070
  • 13
  • 29
1
2
3
23 24