Json.insert
// 1
template<typename K, typename V>
requires std::convertible_to<K, Str> && std::convertible_to<V, Json>
bool insert(K&& key, V&& value) noexcept;
// 2
template<typename V>
requires std::convertible_to<V, Json>
bool insert(const std::size_t index, V&& value) noexcept;
-
If the internal data type is
Obj
, insert the specified key-value pair (overwriting if it already exists) and returntrue
. If the type does not match, returnfalse
(no exception will be thrown). -
If the internal data type is
Arr
and the index is within range (end index allowed), insert the specified element and returntrue
. If the type does not match or the index is out of bounds, returnfalse
(no exception will be thrown).
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 .