How to allocate JSON object on heap space? #446
Replies: 3 comments 2 replies
-
Hi @danielaparker! Could you please help answering this question? Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Apologies, just got back from a long trek in the Pyrenees. You can do it as follows (without a copy)
|
Beta Was this translation helpful? Give feedback.
2 replies
-
Thanks! It helped! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How do I allocate json in stack space? Current implementation
json j = json::parse(raw_string)
creates object in stack space which gets destroyed as soon as it leaves the context.We can't use shared_ptr because underlying library doesn't support it.
I tried
json *j = new json()
but not sure how do I parse a json string and store it inj
?Below code works, but again it this will first create object on stack and then copy it to the j which is inefficient.
Beta Was this translation helpful? Give feedback.
All reactions