CAUTION: SLIPPERY FLOORThe Arduino Library Manager installs the ArduinoJson version 6 by default.
However, using version 5 is highly recommended because version 6 is still in beta stage.
Open the Arduino Library Manager and make sure that ArduinoJson version 5 is installed.
Removes the element at the specified key.
void remove(const char* key); void remove(const String& key); void remove(const std::string& key); void remove(const __FlashStringHelper* key);
key: the key to remove from the object.
JsonObject& object = jsonBuffer.createObject(); object["A"] = 1; object["B"] = 2; object["C"] = 3; object.remove("B"); object.printTo(Serial);
will print the following string to the serial output:
Causes memory leaks
This function doesn’t free the memory allocated to the element in the
This is a conscious design decision made to keep the
JsonBufferfast and small, which is a fundamental principle of the library.
As a consequence, you cannot remove and add elements in a loop, otherwise the
Don’t try to keep the state of your application in a
JsonObject, instead use custom structures.