Using if else statement with json values in jsoncpp : <p>I am trying to do something similar using <code>jsoncpp</code> inside a function which returns json values as strings.</p>

<pre><code>std::string some_function(std::string val){
.
.
.
if(val=="date")
{
    Json::Value my=root["data"]["date"];
    std::cout&lt;&lt;"Date";
}
else if(val=="id")
{
    Json::Value my=root["data"]["id"];
    std::cout&lt;&lt;"ID";
}
else if(val=="art")
{
    Json::Value my=root["data"]["article"];
    std::cout&lt;&lt;"Article";
}
else
{
    return "Error";
}
//Json::Value my=root["data"]["date"]; //this works
return my.toStyledString();
}
</code></pre>

<p>I am able to successfully run json values example: <code>Json::Value my=root["data"]["date"];</code> 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</p>

<blockquote>
  <p>warning: control reaches end of non-void function [-Wreturn-type]</p>
</blockquote>
