Is there a "proper" way to extract an element of array which is a child of an object in JsonCPP?
I'm dealing with JsonRPC objects along the lines of:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"data": [{
"state": 7,
"stateticks":362220
}],
"ticks": 416410
}
}
If I want to pull the first (or, n-th, for that matter) element of the array, by doing
Json::Value& sessionData = object["result"]["data"][0];
I'm getting the error of:
error: ambiguous overload for ‘operator[]’ (operand types are ‘const Json::Value’ and ‘int’)
116 | Json::Value& sessionData = object["result"]["data"][0];
I can bypass this by creating an intermediate variable:
Json::Value& allSessionData = object["result"]["data"];
Json::Value& sessionData = allSessionData[0];
but I'm also dealing with nested arrays and generally I don't like multiplying helper variables like that and I bet there is a better way... can you help?
object["result"]["data"][0u]?0uworks. I still wonder what type is the generic literal0so that Jsoncpp doesn't recognize it as int.json.hcontains the version number. But the compiler may also matter. I can't reproduce this with jsoncpp 1.8.4 and Clang.0uor just casting to int solves my problem.