Skip to content
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

How to erase nested objects inside other objects? #728

Closed
sqwunkly opened this issue Sep 6, 2017 · 3 comments
Closed

How to erase nested objects inside other objects? #728

sqwunkly opened this issue Sep 6, 2017 · 3 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@sqwunkly
Copy link

sqwunkly commented Sep 6, 2017

Hello Niels,

Is it possible to erase/delete nested objects using a similar technique as you've created for adding nested objects inside other objects?

​​j["answer"]["everything"] = 42;

image

Is there an equivalent way to do j.erase(​["answer"]["everything"]; (ie, doesn't work) ?

This ​j​​["answer"]["everything"] = 42; is neat for adding nested objects inside other objects but so far I'm unable to find a corresponding function in your library to delete/erase nested objects. Is there a way to do this?

My apologies if I've missed something obvious. Hoping you can help me with these two questions. Much thanks. Greg

@gregmarr
Copy link
Contributor

gregmarr commented Sep 6, 2017

Have you tried j["answer"].erase("everything");?

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Sep 6, 2017
@sqwunkly
Copy link
Author

sqwunkly commented Sep 6, 2017

Hi gregmarr, no I hadn't tried that. It is the solution I was looking for. Excellent. Nice. Thank you!

@nlohmann nlohmann closed this as completed Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants