Depending on the type of its argument, JsonDocument::remove() either:

  • removes the element at the specified index from the root array
  • removes the member with the specified key in the root object

In other words, JsonDocument::remove() behaves like JsonArray::remove() or JsonObject::remove().

JsonDocument::remove() does nothing if the root value doesn’t match the expected type. For example, if you call remove("key") on an array, the document won’t change.


void remove(size_t index) const;

void remove(const char* key) const;
void remove(const __FlashStringHelper* key) const;
void remove(const String& key) const;
void remove(const std::string& key) const;
void remove(std::string_view key) const;


index: the zero-based position of the array element to remove.

key: the key of the object member to remove

See also