2

から値を変更したい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);
4

2 に答える 2

0

Json::Value& slotList = root["slotList"];

Json::Value& slot = slotList[currentIndex];

スロット[selectIndex] = "1111";

std::cout << root.toStyledString() << std::endl;

于 2013-03-07T01:20:29.197 に答える
0

currentIndexである必要がありますunsigned。これは API の残念な癖であり、ここに記載されています。( を参照してくださいoperator[](int)。)

于 2015-02-16T23:50:27.120 に答える