Closed GoogleCodeExporter closed 9 years ago
[deleted comment]
doc.AddMember(lvl.c_str(), score, doc.GetAllocator());
lvl.c_str() is a temp string, it needs to be duplicated, otherwise when the
function returns the pointer become invalid.
For this situation, you should call
rapidjson::Value name(lvl.c_str(), doc.GetAllocator()); // copy the string
rapidjson::Value value(score);
doc.AddMember(name, value, doc.GetAllocator());
I think it is kinda confusing at first. I will consider making the API more
safe.
Original comment by milo...@gmail.com
on 1 Jul 2014 at 1:32
Further discussion will be in
https://github.com/miloyip/rapidjson/issues/38
Original comment by milo...@gmail.com
on 1 Jul 2014 at 2:07
Original issue reported on code.google.com by
Jeffrey...@gmail.com
on 12 Apr 2013 at 11:31Attachments: