Json.erase
// 1
bool erase(const Str& key) noexcept;
// 2
bool erase(const std::size_t index) noexcept;
-
If the internal data type is
Obj
, delete the key-value pair for the specified key. If the type does not match or the key does not exist, returnfalse
(no exception will be thrown). Returntrue
if the deletion succeeds. -
If the internal data type is
Arr
, delete the element at the specified index. If the type does not match or the index is out of bounds, returnfalse
(no exception will be thrown). Returntrue
if the deletion succeeds.
Exceptions
None.
Complexity
-
Ordered map: logarithmic complexity; hash map: average constant complexity.
-
Linear complexity, depending on the number of trailing elements.
Version
Since v3.0.0 .