I have this piece of code which add some members to a Object type Document
void test01(rapidjson::Document& doc)
{
doc.AddMember("test01", 123, doc.GetAllocator());
char name[] = "test02";
doc.AddMember(name, 2, doc.GetAllocator());
string sname = "test03";
doc.AddMember(sname.c_str(), 3, doc.GetAllocator());
}
and this piece to serialize it
rapidjson::StringBuffer buffer;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer (buffer);
document.Accept (writer);
std::string json = buffer.GetString();
but the value got was
{
"test01": 123,
"ÌÌÌÌÌÌ": 2,
"ÌÌÌÌÌÌ": 3
}
do anybody know why?
based on what vaultah suggested, I'd found out that I have to explicitly create
to force it to use a string-copy constructor, and use
to add to json document.