0
我有一個簡單的JSON格式的文本文件,我有一些麻煩檢索「像素」數組中的值。 以下是文件:檢索另一個JSON對象
{ "luminaire" :
{ "sensors":
{ "pixel" : [2000,2001,2002] }
}
}
我爲了做到這一點寫的代碼如下:
//After parsing success...
Json::Value pixel = root_["luminaire"].get("sensors" , "nothing").get("pixel" , "nopixel");
int value = pixel[0].asInt();
我嘗試過很多辦法做到這一點,但我不斷收到以下錯誤:
terminate called after throwing an instance of 'Json::LogicError'
what(): in Json::Value::operator[](ArrayIndex): requires arrayValue
我也試過
Json::Value:ArrayIndex and root[0]
但我得到同樣的錯誤。
如何檢索「像素」數組中的值?
哦,是正確的,現在工作的感謝! – iMadz