We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have problems with assigning strings to a document. Obviously this is caused by the copy/link mechanism.
my code: (note: to keep the code snippet small, I removed all return value checks)
rapidjson::Document myDoc; rapidjson::Value objValue; setJsonHeader(std::string &jsonstr) { rapidjson::Document d; //>>> this would work: >>> static rapidjson::Document d; d.SetObject(); d.Parse(jsonstr.c_str()); objValue.SetObject(); objValue.AddMember("rpc", d["header"]["rpc"], myDoc.GetAllocator()); objValue.AddMember("uid", d["header"]["uid"], myDoc.GetAllocator()); myDoc.RemoveAllMembers(); myDoc.AddMember("header", objValue, myDoc.GetAllocator()); }
before calling the function, jsonstr contains:
{ "header": { "rpc": "hereIsSomeTextString", "uid": 42 }, ... }
inside setJsonHeader(), all behaves as expected. But after calling function setJsonHeader(), myDoc looks like this:
{ "header": { "rpc": " \u0015\u0001¦¦¦\u0000\u0000omeTextString", "uid": 42 } }
the string is not valid any more.
My current workaround: use the "static" declaration of ["d"](rapidjson::Document d) but then the function is no more re-entrant.
My question: how can I force rapidjson to actualy copy the contents (i.e. std:strings) instead of just linking them?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have problems with assigning strings to a document.
Obviously this is caused by the copy/link mechanism.
my code:
(note: to keep the code snippet small, I removed all return value checks)
before calling the function, jsonstr contains:
inside setJsonHeader(), all behaves as expected.
But after calling function setJsonHeader(), myDoc looks like this:
the string is not valid any more.
My current workaround:
use the "static" declaration of ["d"](rapidjson::Document d)
but then the function is no more re-entrant.
My question:
how can I force rapidjson to actualy copy the contents (i.e. std:strings) instead of just linking them?
The text was updated successfully, but these errors were encountered: