I am attempting to read array data from a boost::property_tree
using the method shown in this question. In that example, the array is first read as a string, converted to a string stream, then read into an array. While implementing that solution, I have noticed that my strings are coming up empty.
Example input (json):
"Object1"
{
"param1" : 10.0,
"initPos" :
{
"":1.0,
"":2.0,
"":5.0
},
"initVel" : [ 0.0, 0.0, 0.0 ]
}
Both of these array notations are interpreted as arrays by the boost json parser. I am confident that the data is present int the property tree, because on invocation of the json writer, the array data is present in the output.
This is an example of what is failing:
std::string paramName = "Object1.initPos";
tempParamString = _runTree.get<std::string>(paramName,"Not Found");
std::cout << "Value: " << tempParamString << std::endl;
When paramName
is "Object1.param1"
I get "10.0" output as a string,
When paramName
is "Object1.initPos"
I get an empty string,
If paramName
is something that does not exist in the tree, "Not Found"
is returned.