If I have a json file:
{ "key1" : "value1", "key2" : "value2" }
using:
Json::Value root;
Json::Reader reader;
std::ifstream in(filePath.c_str());
if (!in)
{
std::string errReason("Cannot open the settings file '");
errReason += filePath;
errReason += "'";
throw std::domain_error(errReason);
}
bool parsingSuccessful = reader.parse(in, root);
if (!parsingSuccessful)
{
std::cout << "Error parsing the string" << std::endl;
}
else
{
std::cout << "Works" << std::endl;
}
Json::Value::Members names = root.getMemberNames();
for (int index = 0; index < names.size(); ++index)
{
std::string key = names[index].asString();
std::string value = root[key].asString();
map_.insert(make_pair(key, value));
std::cout << root[index] << std::endl;
}
i cannot seem to assign any value to variable string 'key'.
Can anyone explain what i am doing wrong?