I have following code but its cannot compiled. I cannot think about a reason, please help.
rapidjson::Document jsonDoc;
jsonDoc.SetObject();
rapidjson::Document::AllocatorType& allocator = jsonDoc.GetAllocator();
rapidjson::Value messageArr(rapidjson::kArrayType);
std::string test = std::string("TEST");
messageArr.PushBack(test.c_str(), allocator);
Giving me following error;
error: no matching function for call to ‘rapidjson::GenericValue >::PushBack(const char*, rapidjson::GenericDocument >::AllocatorType&)’ messageArr.PushBack(test.c_str(), allocator);
You need an allocator to create/copy the string as well:
rapidjson::Value testStr(test.c_str(), allocator);
messageArr.PushBack(testStr, allocator);
Most helpful comment
You need an allocator to create/copy the string as well: