Closed Findus76 closed 4 years ago
Hi, Benoit
Thanks.
I make it work like this,
for (JsonObject::iterator it=Function_object.begin(); it!=Function_object.end() && statusinForLoop; ++it)
{
//Avgör om "R/W" finns och är i rätt typ
if (it->value()["R/W"] == "R")
{
Serial.println("Remove object");
Function_object.remove(it);
}
else if(it->value()["R/W"] == "W")
{
Serial.println("Remove part object");
JsonObject removepart = Function_object[it->key()];
removepart.remove("R/W");
removepart.remove("Description");
}
else
{
Serial.printf("R/W can only bee R or W in function %s\r\n", it->key().c_str());
statusinForLoop = false;
}
}
Is that what you think? Or is there a nicer way?
Brg
Hi @Findus76,
This looks correct, but you can simplify the following line:
JsonObject removepart = Function_object[it->key()];
into
JsonObject removepart = it->value();
Best regards, Benoit
Thanks!
Continued on issue no: #1352 Your example works, thank you very much! The task was to delete all objects where the key was " R " In the objects where key is "W" I want to delete key "R / W" but also "Description"
Example of json string before and desired result
Expect result
Many thanks!
Brg