Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;JsonCpp从arrayValue更改objectValue_C++_Json_Jsoncpp - Fatal编程技术网

C++ C++;JsonCpp从arrayValue更改objectValue

C++ C++;JsonCpp从arrayValue更改objectValue,c++,json,jsoncpp,C++,Json,Jsoncpp,我想更改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",

我想更改
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=“111”//怎么了?不要更改任何内容!天哪!
插槽[selectIndex]。交换(值);
}
Json::StyledWriter编写器;
字符串jsonData=writer.write(root);

Json::Value&slotList=root[“slotList”]

Json::Value&slot=slotList[currentIndex]

插槽[selectIndex]=“1111”


std::cout
currentIndex
需要
无符号
。这是API的一个不幸的怪癖,有文档记录。(请参见
运算符[](int)

其中
currentIndex
selectIndex
set?currentIndex为1,selectIndex为1相同:)