boost :: ptree find? o cómo acceder a matrices profundas? C ++
Llevo demasiado tiempo intentando acceder a un archivo json_reader ptree desde la biblioteca de impulso.
Tengo un archivo json que se encapsula muy a menudo: (pseudo-json :)
"Foo": {
"nameofFoo:"foofoo"
"Bar": [{
"BarFoo":
{ BarFooDeep: {
BarFooDeepDeep: {
"BarFooValue1": 123
"BarFooValue2" : 456
}
}
}
"FooBar": [ {
"FooBarDeep" :[ {
FooBarDeepDeep:[ {
FooBarValue1: "ineedthis"
FooBarValue2: "andthis"
} ]
FooBarDeepDeep1:[ {
FooBarValue1: "ineedthis"
FooBarValue2: "andthis"
} ]
"FooBarDeep" :[ {
FooBarDeepDeep2:[ {
FooBarValue1: "ineedthis"
FooBarValue2: "andthis"
} ]
FooBarDeepDeep3:[ {
FooBarValue1: "ineedthis"
FooBarValue2: "andthis"
} ]
and so on .... won t complete this now...
Ahora solo necesito obtener FooBarValue1 y FooBarValue2 de todos los FooBar.
Sé que ptree pone matrices junto con childs vacíos ("")
Puedo acceder a todos los miembros por iteración sobre todos los niños de forma recursiva.
Pero, ¿no hay una mejor manera de acceder a valores especiales?
¿Cómo funciona ptree find? siempre recibo errores de compilación ...
ptree jsonPT;
read_json( JSON_PATH, jsonPT);
ptree::const_iterator myIT = jsonPT.find("FooBarValue1");
double mlat = boost::lexical_cast<int>(myIT->second.data());
error: conversión de 'boost :: property_tree :: basic_ptree, std :: basic_string> :: assoc_iterator' a un tipo no escalar 'boost :: property_tree :: basic_ptree, std :: basic_string> :: const_iterator' ptree solicitado const_iterator myIT = jsonPT.find ("FooBarValue1");
¿Alguien puede darme una pista útil sobre cómo obtener acceso a este árbol?