I am facing a strange problem : when i try to add a Json variable inside a for loop, it is not written properly in the output file whereas it works well outside the loop (rapidJson v0.11).
Edit : the loop is not the problem but the bug appears even only with brackets
Here is a sample of my code :
rapidjson::Document output;
output.SetObject();
rapidjson::Document::AllocatorType& allocator = output.GetAllocator();
{
std::string s1("test");
output.AddMember("test_field",s1.c_str(), allocator);
}
std::string s2("test");
output.AddMember("test_field2",s2.c_str(), allocator);
rapidjson::FileStream f(stdout);
rapidjson::PrettyWriter<rapidjson::FileStream> writer(f);
output.Accept(writer);
The output I get is :
{"test_field": "\u0000est",
"test_field2": "test"}
So there seems to be a problem with the variable added inside the bracket.. Do you have any idea where it comes from ?