This is my Json array.
{
"colorsArray":[{
"colorName":"red",
"hexValue":"#f00"
},
{
"colorName":"green",
"hexValue":"#0f0"
},
{
"colorName":"blue",
"hexValue":"#00f"
}
]
}
I want to get value 'green'. My c++ code in rapidjson library is
Document document;
document.Parse<0>(jsoncontent.c_str()).HasParseError();
document.Parse(jsoncontent.c_str());
const Value& user = document["colorsArray"];
string name = user["colorName"].GetString();
When I try to access the colorName, I am getting the below Runtime error.
rapidjson::GenericValue<Encoding, Allocator>::MemberIterator
rapidjson::GenericValue<Encoding, Allocator>::FindMember(const
rapidjson::GenericValue<Encoding, SourceAllocator>&) [with SourceAllocator
= rapidjson::MemoryPoolAllocator<>; Encoding = rapidjson::UTF8<>;
Allocator = rapidjson::MemoryPoolAllocator<>;
rapidjson::GenericValue<Encoding, Allocator>::MemberIterator =
rapidjson::GenericMemberIterator<false, rapidjson::UTF8<>,
rapidjson::MemoryPoolAllocator<> >]: Assertion `IsObject()' failed.
Aborted (core dumped)
How can I read a particular value using Rapidjson Library ?