다음 코드가 있지만 컴파일 할 수 없습니다. 나는 이유를 생각할 수 없다.문자열이있는 RapidJson kArrayType
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);
다음과 같은 오류가 표시됩니다.
error: no matching function for call to ‘rapidjson::GenericValue >::PushBack(const char*, rapidjson::GenericDocument >::AllocatorType&)’
messageArr.PushBack(test.c_str(), allocator);
수행
- RapidJosn이 문자열 값의 다른 종류가 있습니다 : 할당 (필요합니다 단순한'const char *'래퍼 (범위를 벗어나면 불어날 것임) 및/또는'짧은 문자열'* 15 ch ars 이하 또는 그와 비슷한 것). 할당자를 원했기 때문에, 당신은 Copy by StrValue를 원한다고 생각했습니다. –