[#BloombergLP-bdljsn-Json-insert-09]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdljsn.adoc[bdljsn]::xref:BloombergLP/bdljsn/Json.adoc[Json]::insert
:relfileprefix: ../../../
:mrdocs:

`insert` overloads

== Synopses

Declared in `&lt;bdljsn&lowbar;json&period;h&gt;`

Insert the specified move&hyphen;insertable `member` into the `JsonObject` held by this object if the key of `member` does not already exist&semi; otherwise, this method has no effect&period; Return a `pair` whose `first` member is an iterator referring to the (possibly newly inserted) `Member` object whose key matches, and whose `second` member is `true` if a new value was inserted, and `false` otherwise&period; `member` is left in a valid but unspecified state&period; If `isNull()`, then the type is changed to object&period; The behavior is undefined unless `isObject()` or `isNull()`, and unless `member&period;first` is valid UTF&hyphen;8 (see `bdlde&colon;&colon;Utf8Util&colon;&colon;isValid`)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/pair-0b.adoc[bsl::pair&lt;JsonObject::Iterator, bool&gt;]
xref:BloombergLP/bdljsn/Json/insert-064.adoc[insert](xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef&lt;JsonObject::Member&gt;] member);
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-064.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonObject` held by this object members created from the specified `memberInitializers`, ignoring those whose keys already exist&period; Return a non&hyphen;`const` reference to this object&period; If `isNull()`, then the type is changed to object&period; The behavior is undefined unless `isObject()` or `isNull()`, and unless the keys of all members are valid UTF&hyphen;8 (see `bdlde&colon;&colon;Utf8Util&colon;&colon;isValid`)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bdljsn/Json.adoc[Json]&
xref:BloombergLP/bdljsn/Json/insert-0f.adoc[insert](std::initializer&lowbar;list&lt;JsonObject&lowbar;MemberInitializer&gt; memberInitializers);
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-0f.adoc[_» more&period;&period;&period;_]#

Insert the specified `member` into the `JsonObject` held by this object if the key of `member` does not already exist&semi; otherwise, this method has no effect&period; Return a `pair` whose `first` member is an iterator referring to the (possibly newly inserted) `Member` object whose key matches, and whose `second` member is `true` if a new value was inserted, and `false` otherwise&period; If `isNull()`, then the type is changed to object&period; The behavior is undefined unless `isObject()` or `isNull()`, and unless `member&period;first` is valid UTF&hyphen;8 (see `bdlde&colon;&colon;Utf8Util&colon;&colon;isValid`)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/pair-0b.adoc[bsl::pair&lt;JsonObject::Iterator, bool&gt;]
xref:BloombergLP/bdljsn/Json/insert-0e5.adoc[insert](xref:BloombergLP/bdljsn/JsonObject/Member.adoc[JsonObject::Member] const& member);
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-0e5.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonArray` held by this object at the specified `position` the specified move&hyphen;insertable `json`, and return an iterator referring to the newly inserted element&period; `json` is left in a valid but unspecified state&period; If an exception is thrown, `&ast;this` is unaffected&period; Throw `bsl&colon;&colon;length&lowbar;error` if `size() &equals;&equals; maxSize()`&period; The behavior is undefined unless `isArray()` and `position` is in the range `&lsqb;theArray()&period;begin() &period;&period; theArray()&period;end()&rsqb;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bdljsn/JsonArray/Iterator-0d.adoc[JsonArray::Iterator]
xref:BloombergLP/bdljsn/Json/insert-065.adoc[insert](
    xref:BloombergLP/bdljsn/JsonArray/ConstIterator.adoc[JsonArray::ConstIterator] position,
    xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef&lt;Json&gt;] json);
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-065.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonArray` held by this object at the specified `position` a copy of the specified `json`, and return an iterator referring to the newly inserted element&period; If an exception is thrown, `&ast;this` is unaffected&period; Throw `bsl&colon;&colon;length&lowbar;error` if `size() &equals;&equals; maxSize()`&period; The behavior is undefined unless `isArray()` and `position` is in the range `&lsqb;theArray()&period;begin() &period;&period; theArray()&period;end()&rsqb;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bdljsn/JsonArray/Iterator-0d.adoc[JsonArray::Iterator]
xref:BloombergLP/bdljsn/Json/insert-07.adoc[insert](
    xref:BloombergLP/bdljsn/JsonArray/ConstIterator.adoc[JsonArray::ConstIterator] position,
    xref:BloombergLP/bdljsn/Json.adoc[Json] const& json);
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-07.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonArray` held by this object at the specified `index` the specified move&hyphen;insertable `json`, and return an iterator referring to the newly inserted element&period; `json` is left in a valid but unspecified state&period; If `isNull()`, then the type is changed to array and `index` must be `0`&period; If an exception is thrown, `&ast;this` is unaffected&period; Throw `bsl&colon;&colon;length&lowbar;error` if `size() &equals;&equals; maxSize()`&period; The (template parameter) type `t&lowbar;INDEX` must be a non&hyphen;`bool` integral type&period; The behavior is undefined unless `isArray()` or `isNull()`, and unless `index` is in the range `&lsqb;0 &period;&period; size()&rsqb;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;INDEX&gt;
xref:BloombergLP/bdljsn/JsonArray/Iterator-0d.adoc[JsonArray::Iterator]
xref:BloombergLP/bdljsn/Json/insert-00.adoc[insert](
    t&lowbar;INDEX index,
    xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef&lt;Json&gt;] json)
requires bsl&colon;&colon;is&lowbar;integral&lt;t&lowbar;INDEX&gt;&colon;&colon;value
                        &amp;&amp; !bsl&colon;&colon;is&lowbar;same&lt;t&lowbar;INDEX, bool&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-00.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonArray` held by this object at the specified `index` a copy of the specified `json`, and return an iterator referring to the newly inserted element&period; If `isNull()`, then the type is changed to array and `index` must be `0`&period; If an exception is thrown, `&ast;this` is unaffected&period; Throw `bsl&colon;&colon;length&lowbar;error` if `size() &equals;&equals; maxSize()`&period; The (template parameter) type `t&lowbar;INDEX` must be a non&hyphen;`bool` integral type&period; The behavior is undefined unless `isArray()` or `isNull()`, and unless `index` is in the range `&lsqb;0 &period;&period; size()&rsqb;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;INDEX&gt;
xref:BloombergLP/bdljsn/JsonArray/Iterator-0d.adoc[JsonArray::Iterator]
xref:BloombergLP/bdljsn/Json/insert-0d.adoc[insert](
    t&lowbar;INDEX index,
    xref:BloombergLP/bdljsn/Json.adoc[Json] const& json)
requires bsl&colon;&colon;is&lowbar;integral&lt;t&lowbar;INDEX&gt;&colon;&colon;value
                        &amp;&amp; !bsl&colon;&colon;is&lowbar;same&lt;t&lowbar;INDEX, bool&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-0d.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonObject` held by this object each `Member` in the range `&lsqb;first, last)&rsqb;` whose key is not already present&period; Return a non&hyphen;`const` reference to this object&period; If `isNull()`, then the type is changed to object&period; The behavior is undefined unless `isObject()` or `isNull()`, `first` and `last` refer to a valid sequence, and the keys of all members are valid UTF&hyphen;8 (see `bdlde&colon;&colon;Utf8Util&colon;&colon;isValid`)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;INPUT&lowbar;ITERATOR&gt;
xref:BloombergLP/bdljsn/Json.adoc[Json]&
xref:BloombergLP/bdljsn/Json/insert-0ec.adoc[insert](
    t&lowbar;INPUT&lowbar;ITERATOR first,
    t&lowbar;INPUT&lowbar;ITERATOR last)
requires !bsl&colon;&colon;is&lowbar;convertible&lt;t&lowbar;INPUT&lowbar;ITERATOR,
                                                 bsl&colon;&colon;string&lowbar;view&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-0ec.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonObject` held by this object a `Member` constructed from the specified `key` and `value` if `key` does not already exist&semi; otherwise, this method has no effect&period; Return a `pair` whose `first` member is an iterator referring to the (possibly newly inserted) `Member` object whose key matches, and whose `second` member is `true` if a new value was inserted, and `false` otherwise&period; If `isNull()`, then the type is changed to object&period; The (template parameter) type `t&lowbar;STRING&lowbar;VIEW` must be convertible to `bsl&colon;&colon;string&lowbar;view`&period; The behavior is undefined unless `isObject()` or `isNull()`, and unless `key` is valid UTF&hyphen;8 (see `bdlde&colon;&colon;Utf8Util&colon;&colon;isValid`)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;VALUE,
    class t&lowbar;STRING&lowbar;VIEW&gt;
xref:bsl/pair-0b.adoc[bsl::pair&lt;JsonObject::Iterator, bool&gt;]
xref:BloombergLP/bdljsn/Json/insert-03.adoc[insert](
    t&lowbar;STRING&lowbar;VIEW const& key,
    t&lowbar;VALUE&& value)
requires !bsl&colon;&colon;is&lowbar;integral   &lt;t&lowbar;STRING&lowbar;VIEW&gt;&colon;&colon;value
                          &amp;&amp; bsl&colon;&colon;is&lowbar;convertible&lt;t&lowbar;STRING&lowbar;VIEW,
                                                 bsl&colon;&colon;string&lowbar;view&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-03.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonArray` held by this object at the specified `position` the values in the range `&lsqb;first, last)&rsqb;`, and return an iterator referring to the first newly inserted element&period; If an exception is thrown, `&ast;this` is unaffected&period; Throw `bsl&colon;&colon;length&lowbar;error` if `size() &plus; distance(first, last) &gt; maxSize()`&period; The behavior is undefined unless `isArray()` and `position` is in the range `&lsqb;theArray()&period;begin() &period;&period; theArray()&period;end()&rsqb;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;INPUT&lowbar;ITERATOR&gt;
xref:BloombergLP/bdljsn/JsonArray/Iterator-0d.adoc[JsonArray::Iterator]
xref:BloombergLP/bdljsn/Json/insert-02.adoc[insert](
    xref:BloombergLP/bdljsn/JsonArray/ConstIterator.adoc[JsonArray::ConstIterator] position,
    t&lowbar;INPUT&lowbar;ITERATOR first,
    t&lowbar;INPUT&lowbar;ITERATOR last);
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-02.adoc[_» more&period;&period;&period;_]#

Insert into the `JsonArray` held by this object at the specified `index` the values in the range `&lsqb;first, last)&rsqb;`, and return an iterator referring to the first newly inserted element&period; If `isNull()`, then the type is changed to array and `index` must be `0`&period; If an exception is thrown, `&ast;this` is unaffected&period; Throw `bsl&colon;&colon;length&lowbar;error` if `size() &plus; distance(first, last) &gt; maxSize()`&period; The (template parameter) type `t&lowbar;INDEX` must be a non&hyphen;`bool` integral type&period; The behavior is undefined unless `isArray()` or `isNull()`, and unless `index` is in the range `&lsqb;0 &period;&period; size()&rsqb;`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;INDEX,
    class t&lowbar;INPUT&lowbar;ITERATOR&gt;
xref:BloombergLP/bdljsn/JsonArray/Iterator-0d.adoc[JsonArray::Iterator]
xref:BloombergLP/bdljsn/Json/insert-01.adoc[insert](
    t&lowbar;INDEX index,
    t&lowbar;INPUT&lowbar;ITERATOR first,
    t&lowbar;INPUT&lowbar;ITERATOR last)
requires bsl&colon;&colon;is&lowbar;integral&lt;t&lowbar;INDEX&gt;&colon;&colon;value
                        &amp;&amp; !bsl&colon;&colon;is&lowbar;same&lt;t&lowbar;INDEX, bool&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bdljsn/Json/insert-01.adoc[_» more&period;&period;&period;_]#


[.small]#Created with https://www.mrdocs.com[MrDocs]#
