Json: How to erase nested objects inside other objects?

Created on 6 Sep 2017  ·  3Comments  ·  Source: nlohmann/json

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

question proposed fix

Most helpful comment

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

All 3 comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jmlemetayer picture jmlemetayer  ·  3Comments

koemeet picture koemeet  ·  4Comments

SimplyLiz picture SimplyLiz  ·  3Comments

zkelo picture zkelo  ·  3Comments

Prati369 picture Prati369  ·  4Comments