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
6
votes
2 answers

Writing comments to ini file with boost::property_tree::ptree

Is there any way to write comments in an ini file using boost::property::ptree? Something like that: void save_ini(const std::string& path) { boost::property_tree::ptree pt; int first_value = 1; int second_value = 2; …
Jeff Bencteux
  • 1,406
  • 16
  • 27
6
votes
3 answers

performance is very bad to construct boost property tree from json file?

I am using boost property tree to load/dump json file. However, the performance is very bad. For example, I have a json file whose size is 1.8M. The boost C++ program spends 3 seconds to load the json file and construct the property tree. If I use…
limi
  • 832
  • 7
  • 19
6
votes
1 answer

Boost property tree issue when converting to Unicode

Ok, first off I'm not a C++ developer by nature; I've managed to put some stuff together and it works fine, but I'm sure through the eyes of an expert it looks like garbage =) So I have a freeware app that I've made which uses Property Tree from the…
CapersL
  • 174
  • 2
  • 7
5
votes
2 answers

Boost property_tree error: conversion of data to type "j" failed when getting an element in a .ini file

I have a .ini file contains below data [SYSTEM] num_of_vps = 1 And I have this code to read an element in .ini file. (uint defined as typedef unsigned int uint) boost::property_tree::ptree pt;…
5
votes
1 answer

Crash in boost::coroutine library when used alongside boost::property_tree XML parser

I'm using Simple-Web-Server library for creating simple web service for translation of XML to JSON and vice versa. On its turn it uses several boost libraries as well boost::coroutine among them. For XML<->JSON conversion I'm using…
bobeff
  • 3,543
  • 3
  • 34
  • 62
5
votes
1 answer

Parse JSON file (C++ Boost)

I would like to use the Boost (Property Tree) library to parse the following valid JSON file: { "user": { "userID": "5C118C8D-AA65-49C0-B907-348DE87D6665", "dateProperty": "05-06-2015" }, "challenges": [ { …
Ed Johns
  • 211
  • 3
  • 11
5
votes
2 answers

How to get enum from boost::property_tree?

How do I get an enum from a boost::property_tree? This is my "non-working" example. config.xml EMISSION::EMIT1 42 main.cpp #include #include…
Raymond Valdes
  • 1,161
  • 1
  • 9
  • 15
5
votes
2 answers

Printing the xml generated by the boost property tree

I tested boost::property_tree and it was good: I can load an XML, extract the elements, save the XML, etc. But, is it possible to generate an XML and print it? I don't want to save it. void debug_settings::load(const std::string &filename) { …
Kathick
  • 1,395
  • 5
  • 19
  • 30
5
votes
2 answers

boost property tree not able retrive records after parsing json

I have a sample json record that I have parsed via boost json parser and saved it to boost property tree to get all key value pairs.ia following code I am able to get first attribute of tree but how can I get second attributes value ? when I try to…
Dhimant Jayswal
  • 123
  • 1
  • 10
4
votes
2 answers

Adding unnamed nodes to boost::property_tree::ptree

I need to add unnamed nodes to a boost::property_tree::ptree just like it's JSON parser does for arrays. However when I want to do it I get such assertion during runtime: Assertion failed: !p.empty() && "Empty path not allowed for put_child.",…
sim642
  • 751
  • 7
  • 14
4
votes
0 answers

Iterating over variables within an XML file using Boost Property Tree

Could anyone help me with iterating over the variables within the XML file I've got, using boost property tree?
Sent1nel
  • 509
  • 1
  • 7
  • 21
4
votes
3 answers

How to forward declare boost::ptree::iterator

I'd like to use boost ptree in my project but since ptree.hpp causes about another 1000 header files to be included this increases compile times drastically (e.g. from 1s to 7s) and as it's needed in over 20 different cpp files this is not…
tom
  • 333
  • 4
  • 12
4
votes
2 answers

boost access float array from JSON data

I have some JSON data collected via boost and I can not work out how to access some of the data that is in an array: JSON data : {"dvm_gnd": {"num" : 4, "value": [1,2,3,4]}, "xx_gn" : {"num : 1, "value": 5}} I can easily get the "num" and single…
Ross W
  • 1,300
  • 3
  • 14
  • 24
4
votes
1 answer

Access to specific index in ptree array

I am using boost library to manipulate a JSON file and I would like to access to a specific index of an array in this JSON. boost::property_tree::ptree& jsonfile; const boost::property_tree::ptree& array = jsonfile.get_child("my_array"); What I…
klaus
  • 754
  • 8
  • 28
4
votes
0 answers

Combining boost::program_options and JSON

I am currently using boost::program_options to parse command line and config-file arguments. However, recently I have realised I need to be able to pass my program a list of options which could be very easily summarised using e.g. JSON…