我想更改slotList
的值。
slotList[1][1] = "1234";
我该如何解决这个问题?
这是我试过的:
JSON:
{
"slotList" : [
[ "1452", "1452", "1452", "1452", "1452" ],
[ "1452", "1452", "1452", "1452", "1452" ],
[ "1452", "1452", "1452", "1452", "1452" ],
[ "1452", "1452", "1452", "1452", "1452" ],
[ "1452", "1452", "1452", "1452", "1452" ]
]
}
代码:
if (bIsParsed == true)
{
Json::Value slotList = root["slotList"];
Json::Value slot = slotList[currentIndex];
Json::Value value = "111"; // what is wrong? do not change anything! OMG!
slot[selectIndex].swap(value);
}
Json::StyledWriter writer;
string jsonData = writer.write(root);
答案 0 :(得分:0)
的Json ::值及安培; slotList = root [" slotList"];
的Json ::值及安培; slot = slotList [currentIndex];
slot [selectIndex] =" 1111&#34 ;;
std :: cout<< root.toStyledString()<<的std :: ENDL;
答案 1 :(得分:0)
currentIndex
需要unsigned
。这是API的一个不幸的怪癖,记录为here。 (见operator[](int)
。)