I am trying to use an std::string with RapidJson
using namespace std;
using namespace rapidjson;
const char* json = "{\n"
" \"id\": null\n"
" \"code\": null\n"
"}";
Document d;
string a = "myString";
d["myValue"].SetString(a); //error: no matching member function for call to 'SetString' in the compiler
我想通过使用std::string来使用rapidjson编辑我的json文件,但是它不起作用。顺便说一下,我是c++的新手,所以如果这是个愚蠢的问题,请原谅。
编辑:我尝试了Jorge Perez提供的解决方案,但我仍然收到以下错误:
Original Answer翻译成"最初的回答"
/include/rapidjson/document.h:1139: rapidjson::GenericValue<Encoding, Allocator>& rapidjson::GenericValue<Encoding, Allocator>::operator[](const rapidjson::GenericValue<Encoding, SourceAllocator>&) [with SourceAllocator = rapidjson::MemoryPoolAllocator<>; Encoding = rapidjson::UTF8<>; Allocator = rapidjson::MemoryPoolAllocator<>]: Assertion `false' failed.
最初的回答
有什么想法吗?