我有以下代码,但它无法编译。我想不出原因了,拜托了。
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);给我跟随错误;
错误:对‘rapidjson::GenericValue >::PushBack(const char*,rapidjson::GenericDocument >::AllocatorType&)的调用没有匹配函数 messageArr.PushBack(test.c_str(),分配器);
发布于 2016-09-22 06:27:22
编辑-解决办法:
std::string test = std::string("TEST");
rapidjson::Value strVal;
strVal.SetString(test.c_str(), test.length(), allocator);
messageArr.PushBack(strVal, allocator);请参阅RapidJson教程-创建字符串
流畅的风格:
messageArr.PushBack(
rapidjson::Value{}.SetString(test.c_str(), test.length(), allocator),
allocator
);发布于 2018-12-04 10:38:13
using namespace rapidjson;
using namespace std;
Value array(kArrayType);
string test = "TEST";
Value cat(test.c_str(), allocator);
array.PushBack(cat, allocator);https://stackoverflow.com/questions/39631632
复制相似问题