問題描述
碰到以下開頭的內容,問題的解決方式
/usr/include/rapidjson/document.h:1497: rapidjson::GenericValue<Encoding, Allocator>& rapidjson::GenericValue<Encoding, Allocator>::operator[](rapidjson::SizeType) [with Encoding = rapidjson::UTF8<>; Allocator = rapidjson::MemoryPoolAllocator<>; rapidjson::SizeType = unsigned int]: Assertion `IsArray()' failed.
問題來源
我原先想進行以下的操作
int n = document["key1"][0];
出問題的段落在於我嘗試指派一個不存在的位置給變數,
「Assertion `IsArray()’ failed.」這段就有點出了,問題點在於我所指派的值並不是「Array」。
解決方法
請再檢查一下自己想嘗試存取的 Array 位置,
是否如同自己想像的「那個位置」是否真的存在。