C++ JsonCpp Change objectValue from an arrayValue
C++ JsonCpp Change objectValue from an arrayValue
我想更改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);
Json::值&slotList=root["slotList"];
Json::价值&slot=slotList[currentIndex];
slot[selectIndex]="1111";
std::cout<lt;root.toStyledString((<lt;std::endl;
currentIndex
需要是unsigned
。这是API的一个不幸的怪癖,这里记录了这一点。(参见operator[](int)
。(
相关文章:
- N-API include an .so or dll
- C++/SDL "initial value of reference to a non-const must be an lvalue"
- 如何理解"abstract-declarator containing an ellipsis shall only be used in a parameter-declaration"
- 如何在数据库程序中添加"reduce the quantity of an item"功能?
- C++线程"Call to non-static member function without an object argument"
- Atom gpp编译器给出"'C:UsersadminUser' is not recognized as an internal or..."错误
- 尝试在类中编译内核,出现错误"__init__() got an unexpected keyword argument 'kernel'"
- 指向对象生存期之外的已分配内存的指针是"invalid pointer[s]"还是"pointer[s] to an object"?
- 如何修复" State Error (active) E0513 a value of type "const wchar_t *" cannot be assigned to an entity o
- C++ libtins "An invalid handle was specified"
- "terminate called after throwing an instance of std::invalid_argument' what(): stoi ?"
- Hash for a std::pair, for use in an unordered_map
- Divide et impera sum of the elements of an array bug
- 为什么"an inherited constructor is not a candidate for initialization from an expression of the same or
- 根据标准,究竟什么是"declaration of an object"
- shared_ptr to an array
- Truncate an AnsiString
- "error: subscripted value is not an array, pointer, or vector",我正在使用字符串
- LLVM:如何修复"Referring to an argument in another function"
- C++ JsonCpp Change objectValue from an arrayValue