I am trying to do something similar using jsoncpp
inside a function which returns json values as strings.
std::string some_function(std::string val){
.
.
.
if(val=="date")
{
Json::Value my=root["data"]["date"];
std::cout<<"Date";
}
else if(val=="id")
{
Json::Value my=root["data"]["id"];
std::cout<<"ID";
}
else if(val=="art")
{
Json::Value my=root["data"]["article"];
std::cout<<"Article";
}
else
{
return "Error";
}
//Json::Value my=root["data"]["date"]; //this works
return my.toStyledString();
}
I am able to successfully run json values example: Json::Value my=root["data"]["date"];
outside the if else statement(comment out code) but when i tried to run these json values inside an if-else-if statment it shows this error
warning: control reaches end of non-void function [-Wreturn-type]