Remove item from array based on it's value. #3488
Answered
by
falbrechtskirchinger
nitanmarcel
asked this question in
Q&A
-
Having the json bellow, how can I get the array containing The json array can get bigger so the item is not always in the same position so before deleting it I have to find it's index.
|
Beta Was this translation helpful? Give feedback.
Answered by
falbrechtskirchinger
May 11, 2022
Replies: 1 comment
-
Try this:
auto it = j.begin();
for(; it != j.end(); ++it) {
if(it->at("title") == "My Game2")
break;
}
if(it != j.end()) j.erase(it); https://json.nlohmann.me/api/basic_json/begin/ |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nlohmann
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this:
https://json.nlohmann.me/api/basic_json/begin/
https://json.nlohmann.me/api/basic_json/at/
https://json.nlohmann.me/api/basic_json/erase/