-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
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
Efficient way to set a json
object as value into another json
key
#1406
Comments
Yes, this would definitely be more efficient:
|
Already using it, thanks :) |
Sorry, just a question: Is there any way to optimize this?: // Allocate empty object for "data" key:
response["data"] = json::object();
// Get iterator to "data" object:
auto dataIterator = response.find("data"); Obviously the // Allocate empty object for "data" key and get its iterator:
auto dataIterator = response.addKeyValue("data", json::object()); ...where Obviously it does not exist, just wondering if it makes sense :) |
Read what I posted above again, and I think you'll find your answer. Maybe this will help:
|
Ok, so you are directly passing I have to remove some asserts that check |
I've a function somewhere that creates and returns a
json data
object, and I want to use such ajson data
as value into the "data" key of anotherjson response
object.Currently I'm doing something like this, and just wonder whether there is a way to avoid the
data
copy:I expect there is no magic here and the
json data
returned byfoo.GetJsonData()
is being mem copied intoresponse["data"]
. May be I should, instead, do something like this?:Then,
void Foo::GetJsonData(json::iterator dataIterator)
would do something like:Does it make any sense?
The text was updated successfully, but these errors were encountered: