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

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;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;INDEX&gt;
xref:BloombergLP/bdljsn/JsonArray/Iterator-0d.adoc[JsonArray::Iterator]
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]#Created with https://www.mrdocs.com[MrDocs]#
