I need to read a json file with jsoncpp library.
I have this file:
{"one":false,"two":[{"id":"first"},{"id":"second"}],"three":550}
If i need to read only the first id of "two" element, i use:
std::string contents; //Contain the file
Json::Value root;
Json::Reader reader;
reader.parse(contents, root, false);
std::string aux = root["two"][0]["id"].asString();
It works fine in Linux, but when i try it in Windows i have this error:
error: ambiguous overload for 'operator[]' in 'root.Json::Value::operator[](((const char*)"two"))[0]'
Why it happens and how can i fix this? Thanks.
Solved: There are two operator[]
, one with an int
as parameter and other with a const char
as parameter, and the compiler doesn't know who to use in Windows, but yes in Linux. Now i use [0u]
instead [0]
to indicate a number as parameter and it works fine.