[#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;`

Move&hyphen;insert `member` into the held object if its key is new&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 members from `memberInitializers` into the held object&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 `member` into the held object if its key is new&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;_]#

Move&hyphen;insert `json` at `position` in the held array&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 a copy of `json` at `position` in the held array&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;_]#

Move&hyphen;insert `json` at `index` in the held array&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 a copy of `json` at `index` in the held array&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 members from `&lsqb;first, last)&rsqb;` into the held object&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 a member from `key` and `value` into the held object if new&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 `&lsqb;first, last)&rsqb;` at `position` in the held array&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 `&lsqb;first, last)&rsqb;` at `index` in the held array&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;_]#

== Return Value

* a pair of an iterator to the element and a `bool` that is `true` if inserted
* a reference providing modifiable access to this object
* an iterator referring to the newly inserted element
* a pair of an iterator to the element and a `bool` that is `true` if a new member was inserted

== Parameters

[cols="1,4"]
|===
| Name| Description
| *member*
| key&sol;value pair to insert
| *memberInitializers*
| initializer&hyphen;list of members
| *position*
| insertion iterator
| *json*
| value to insert
| *index*
| insertion position
| *first*
| beginning of the source range
| *last*
| end of the source range
| *key*
| UTF&hyphen;8 member name
| *value*
| member value
|===


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