JsonVariant::clear() sets the variant pointed by the JsonVariant to null.

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.

Prefer JsonDocument::clear() which doesn’t leak memory.


void clear() const;

See also