template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator></div>
<p>Creates a JSON object value from a given initializer list. The initializer lists elements must be pairs, and their first elments must be strings. If the initializer list is empty, the empty object <code>{}</code> is created.</p>
<dlclass="section note"><dt>Note</dt><dd>This function is only added for symmetry reasons. In contrast to the related function <aclass="el"href="classnlohmann_1_1basic__json.html">basic_json</a><aclass="el"href="classnlohmann_1_1basic__json_a53590b99e380c464a83a0a5edf6da9ab.html#a53590b99e380c464a83a0a5edf6da9ab"title="explicitly create an array from an initializer list ">array(list_init_t)</a>, there are no cases which can only be expressed by this function. That is, any initializer list <em>init</em> can also be passed to the initializer list constructor <aclass="el"href="classnlohmann_1_1basic__json_a444d8376d63d7a5edb85f33bc5976c14.html#a444d8376d63d7a5edb85f33bc5976c14">basic_json(list_init_t, bool, value_t)</a>.</dd></dl>
<tr><tdclass="paramname">std::domain_error</td><td>if <em>init</em> is not a pair whose first elements are strings; thrown by <aclass="el"href="classnlohmann_1_1basic__json_a444d8376d63d7a5edb85f33bc5976c14.html#a444d8376d63d7a5edb85f33bc5976c14">basic_json(list_init_t, bool, value_t)</a></td></tr>
</table>
</dd>
</dl>
<dlclass="section user"><dt>Complexity</dt><dd>Linear in the size of <em>init</em>.</dd></dl>
<dlclass="section user"><dt>Example</dt><dd>The following code shows an example for the <aclass="el"href="classnlohmann_1_1basic__json_afb9664e6f30038e691f2e864e7f6a740.html#afb9664e6f30038e691f2e864e7f6a740">object</a> function. <divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="preprocessor">#include <json.hpp></span></div>
<divclass="ttc"id="classnlohmann_1_1basic__json_html"><divclass="ttname"><ahref="classnlohmann_1_1basic__json.html">nlohmann::basic_json</a></div><divclass="ttdoc">a class to store JSON values </div><divclass="ttdef"><b>Definition:</b> json.hpp:121</div></div>
<divclass="ttc"id="namespacenlohmann_html"><divclass="ttname"><ahref="namespacenlohmann.html">nlohmann</a></div><divclass="ttdoc">namespace for Niels Lohmann </div><divclass="ttdef"><b>Definition:</b> json.hpp:56</div></div>
<divclass="ttc"id="classnlohmann_1_1basic__json_afb9664e6f30038e691f2e864e7f6a740_html_afb9664e6f30038e691f2e864e7f6a740"><divclass="ttname"><ahref="classnlohmann_1_1basic__json_afb9664e6f30038e691f2e864e7f6a740.html#afb9664e6f30038e691f2e864e7f6a740">nlohmann::basic_json::object</a></div><divclass="ttdeci">static basic_json object(list_init_t init=list_init_t())</div><divclass="ttdoc">explicitly create an object from an initializer list </div><divclass="ttdef"><b>Definition:</b> json.hpp:1005</div></div>
</div><!-- fragment --> Output: <preclass="fragment">{}
{}
{"one":1,"two":2}
</pre> The example code above can be translated with<preclass="fragment">g++ -std=c++11 -Isrc doc/examples/object.cpp -o object </pre>.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="classnlohmann_1_1basic__json_a444d8376d63d7a5edb85f33bc5976c14.html#a444d8376d63d7a5edb85f33bc5976c14"title="create a container (array or object) from an initializer list ">basic_json(list_init_t, bool, value_t)</a> - create a JSON value from an initializer list </dd>
<dd>
<aclass="el"href="classnlohmann_1_1basic__json.html"title="a class to store JSON values ">basic_json</a><aclass="el"href="classnlohmann_1_1basic__json_a53590b99e380c464a83a0a5edf6da9ab.html#a53590b99e380c464a83a0a5edf6da9ab"title="explicitly create an array from an initializer list ">array(list_init_t)</a> - create a JSON <aclass="el"href="classnlohmann_1_1basic__json_a53590b99e380c464a83a0a5edf6da9ab.html#a53590b99e380c464a83a0a5edf6da9ab"title="explicitly create an array from an initializer list ">array</a> value from an initializer list </dd></dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->