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相同:)