Hello,
Can anyone please tell me how I can access the value of menu.item1.element1-1 (which would be "value1-1" with the jsoncpp library. For some reason I dont seem to be able to get that value.
// here is the json
Code:
"menu":{
"item1":{
"element1-1":"value1-1",
"element1-2":"value1-2",
"element1-3":"value1-3"
},
"item2":{
"element2-1":"value2-1",
"element2-2":"value2-2",
"element2-3":"value2-3"
},
}
}
//here is the cpp code
Code:
Json::Value root;
Json::Reader reader;
constJson::Value defValue;
std::ifstream ifile("inputjson.txt");
bool isJsonOK =( ifile != NULL && reader.parse(ifile, root));
if(isJsonOK)
{
Json::Value val = root.get("menu","");
for(Json::Value::iterator it = val.begin(); it != val.end();++it)
{
Json::Value key = it.key();
Json::Value value =(*it);
// how do i get the details of 'menuValue'
const Json::Value menuValue = root["menu"]["item1"];
}
}