Is it possible to have a source json where you copy a subkey to a new json? #312
Unanswered
jasonmnemonic
asked this question in
Q&A
Replies: 1 comment 4 replies
-
The assignment
should have worked, but there seems to be a defect for the assignment overload such that this doesn't compile. For non const json values, the bracket notation actually returns a proxy, and the assignment operator on the proxy appears to have an issue with overloads. I need to look at that. But you can do either of these:
Both will give you
(The second is more efficient.) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Daniel.
Thanks for the great library and hard work. It is a cool library. ;-)
A question on json and maybe anyone can answer this (thanks):
Say, I have a source json:
When I make a new
jsoncons::json originalJsonDoc
usingjson::parse
to parse the string above. Next, I create a newjsoncons:json newJsonDoc
that is empty.In my new json, I am interested to
newJsonDoc[ "previous-postcode" ] = jsonRoot[ "previous-postcode" ].to_string();
but this returns me a string like{"previous-postcode": "{ \"postcode1\":0, \"postcode2\":5, \"postcode2\":9 }"}
.Is there a way to do something like
newJsonDoc[ "previous-postcode" ] = jsonRoot[ "previous-postcode" ]
so that when Idump-pretty
, I will get{"previous-postcode": {"postcode1":0, "postcode2":5, "postcode3":9 }}
.I think there is a way but I am having trouble to locate it.
Thank you! ;-)
Beta Was this translation helpful? Give feedback.
All reactions