A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://arduinojson.org/v6/api/jsondocument/remove/ below:

JsonDocument::remove() | ArduinoJson 6

Description

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

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.

Causes memory leaks ⚠️

Because JsonDocument contains a monotonic allocator, this function cannot release the memory associated with the removed value.
Consequently, you cannot call this function in a loop; otherwise, the JsonDocument will overflow.

Signature
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;
Arguments

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

key: the key of the object member to remove

With an array
StaticJsonDocument<256> doc;
doc.add("Ned");
doc.add("Maude");
doc.add("Rod");
doc.add("Todd");
doc.remove(1);  // removes "Maude"
serializeJson(doc, Serial);  // prints ["Ned","Rod","Todd"]
With an object
StaticJsonDocument<256> doc;
doc["name"] = "Homer";
doc["age"] = 38;
doc["weight"] = 239;
doc.remove("age");
serializeJson(doc, Serial);  // prints {"name":"Homer","weight":239}
See also
  1. Home
  2. Version 6
  3. API
  4. JsonDocument
  5. remove()

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4