</code></pre></div></div><divclass="admonition note"><pclass=admonition-title>Note</p><p>Do not use <codeclass=highlight><spanclass=nb>include</span><spanclass=p>(</span><spanclass=s>nlohmann_json/CMakeLists.txt</span><spanclass=p>)</span></code>, since that carries with it unintended consequences that will break the build. It is generally discouraged (although not necessarily well documented as such) to use <codeclass=highlight><spanclass=nb>include</span><spanclass=p>(</span><spanclass=s>...</span><spanclass=p>)</span></code> for pulling in other CMake projects anyways.</p></div><h3id=supporting-both>Supporting Both<aclass=headerlinkhref=#supporting-bothtitle="Permanent link">¶</a></h3><p>To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin to the following.</p><divclass="admonition example"><pclass=admonition-title>Example</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>project</span><spanclass=p>(</span><spanclass=s>ExampleProject</span><spanclass=w></span><spanclass=s>LANGUAGES</span><spanclass=w></span><spanclass=s>CXX</span><spanclass=p>)</span>
</code></pre></div></div><divclass="admonition note"><pclass=admonition-title>Note</p><p>Do not use <codeclass=highlight><spanclass=nb>include</span><spanclass=p>(</span><spanclass=s>nlohmann_json/CMakeLists.txt</span><spanclass=p>)</span></code>, since that carries with it unintended consequences that will break the build. It is generally discouraged (although not necessarily well documented as such) to use <codeclass=highlight><spanclass=nb>include</span><spanclass=p>(</span><spanclass=s>...</span><spanclass=p>)</span></code> for pulling in other CMake projects anyways.</p></div><h3id=supporting-both>Supporting Both<aclass=headerlinkhref=#supporting-bothtitle="Permanent link">¶</a></h3><p>To allow your project to support either an externally supplied or an embedded <abbrtitle="JavaScript Object Notation">JSON</abbr> library, you can use a pattern akin to the following.</p><divclass="admonition example"><pclass=admonition-title>Example</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>project</span><spanclass=p>(</span><spanclass=s>ExampleProject</span><spanclass=w></span><spanclass=s>LANGUAGES</span><spanclass=w></span><spanclass=s>CXX</span><spanclass=p>)</span>
<spanclass=nb>option</span><spanclass=p>(</span><spanclass=s>EXAMPLE_USE_EXTERNAL_JSON</span><spanclass=w></span><spanclass=s2>"Use an external JSON library"</span><spanclass=w></span><spanclass=s>OFF</span><spanclass=p>)</span>
</code></pre></div><p><code>thirdparty/nlohmann_json</code> is then a complete copy of this source tree.</p></div><h3id=fetchcontent>FetchContent<aclass=headerlinkhref=#fetchcontenttitle="Permanent link">¶</a></h3><p>Since CMake v3.11, <ahref=https://cmake.org/cmake/help/v3.11/module/FetchContent.html>FetchContent</a> can be used to automatically download a release as a dependency at configure type.</p><divclass="admonition example"><pclass=admonition-title>Example</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>cmake_minimum_required</span><spanclass=p>(</span><spanclass=s>VERSION</span><spanclass=w></span><spanclass=s>3.11</span><spanclass=p>)</span>
</code></pre></div><p><code>thirdparty/nlohmann_json</code> is then a complete copy of this source tree.</p></div><h3id=fetchcontent>FetchContent<aclass=headerlinkhref=#fetchcontenttitle="Permanent link">¶</a></h3><p>Since CMake v3.11, <ahref="https://cmake.org/cmake/help/v3.11/module/FetchContent.html">FetchContent</a> can be used to automatically download a release as a dependency at configure type.</p><divclass="admonition example"><pclass=admonition-title>Example</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>cmake_minimum_required</span><spanclass=p>(</span><spanclass=s>VERSION</span><spanclass=w></span><spanclass=s>3.11</span><spanclass=p>)</span>
</code></pre></div><p>However, the repository <ahref=https://github.com/nlohmann/json>https://github.com/nlohmann/json</a> download size is quite large.</p></div><h2id=cmake-options>CMake Options<aclass=headerlinkhref=#cmake-optionstitle="Permanent link">¶</a></h2><h3id=json_buildtests><code>JSON_BuildTests</code><aclass=headerlinkhref=#json_buildteststitle="Permanent link">¶</a></h3><p>Build the unit tests when <ahref=https://cmake.org/cmake/help/latest/command/enable_testing.html><code>BUILD_TESTING</code></a> is enabled. This option is <code>ON</code> by default if the library's CMake project is the top project. That is, when integrating the library as described above, the test suite is not built unless explicitly switched on with this option.</p><h3id=json_ci><code>JSON_CI</code><aclass=headerlinkhref=#json_cititle="Permanent link">¶</a></h3><p>Enable CI build targets. The exact targets are used during the several CI steps and are subject to change without notice. This option is <code>OFF</code> by default.</p><h3id=json_diagnostics><code>JSON_Diagnostics</code><aclass=headerlinkhref=#json_diagnosticstitle="Permanent link">¶</a></h3><p>Enable <ahref=../../home/exceptions/#extended-diagnostic-messages>extended diagnostic messages</a> by defining macro <ahref=../../api/macros/json_diagnostics/><code>JSON_DIAGNOSTICS</code></a>. This option is <code>OFF</code> by default.</p><h3id=json_diagnostic_positions><code>JSON_Diagnostic_Positions</code><aclass=headerlinkhref=#json_diagnostic_positionstitle="Permanent link">¶</a></h3><p>Enable position diagnostics by defining macro <ahref=../../api/macros/json_diagnostic_positions/><code>JSON_DIAGNOSTIC_POSITIONS</code></a>. This option is off by default.</p><h3id=json_disableenumserialization><code>JSON_DisableEnumSerialization</code><aclass=headerlinkhref=#json_disableenumserializationtitle="Permanent link">¶</a></h3><p>Disable default <code>enum</code> serialization by defining the macro <ahref=../../api/macros/json_disable_enum_serialization/><code>JSON_DISABLE_ENUM_SERIALIZATION</code></a>. This option is <code>OFF</code> by default.</p><h3id=json_fasttests><code>JSON_FastTests</code><aclass=headerlinkhref=#json_fastteststitle="Permanent link">¶</a></h3><p>Skip expensive/slow test suites. This option is <code>OFF</code> by default. Depends on <code>JSON_BuildTests</code>.</p><h3id=json_globaludls><code>JSON_GlobalUDLs</code><aclass=headerlinkhref=#json_globaludlstitle="Permanent link">¶</a></h3><p>Place user-defined string literals in the global namespace by defining the macro <ahref=../../api/macros/json_use_global_udls/><code>JSON_USE_GLOBAL_UDLS</code></a>. This option is <code>OFF</code> by default.</p><h3id=json_implicitconversions><code>JSON_ImplicitConversions</code><aclass=headerlinkhref=#json_implicitconversionstitle="Permanent link">¶</a></h3><p>Enable implicit conversions by defining macro <ahref=../../api/macros/json_use_implicit_conversions/><code>JSON_USE_IMPLICIT_CONVERSIONS</code></a>. This option is <code>ON</code> by default.</p><h3id=json_install><code>JSON_Install</code><aclass=headerlinkhref=#json_installtitle="Permanent link">¶</a></h3><p>Install CMake targets during install step. This option is <code>ON</code> by default if the library's CMake project is the top project.</p><h3id=json_multipleheaders><code>JSON_MultipleHeaders</code><aclass=headerlinkhref=#json_multipleheaderstitle="Permanent link">¶</a></h3><p>Use non-amalgamated version of the library. This option is <code>OFF</code> by default.</p><h3id=json_systeminclude><code>JSON_SystemInclude</code><aclass=headerlinkhref=#json_systemincludetitle="Permanent link">¶</a></h3><p>Treat the library headers like system headers (i.e., adding <code>SYSTEM</code> to the <ahref=https://cmake.org/cmake/help/latest/command/target_include_directories.html><code>target_include_directories</code></a> call) to checks for this library by tools like Clang-Tidy. This option is <code>OFF</code> by default.</p><h3id=json_valgrind><code>JSON_Valgrind</code><aclass=headerlinkhref=#json_valgrindtitle="Permanent link">¶</a></h3><p>Execute test suite with <ahref=https://valgrind.org>Valgrind</a>. This option is <code>OFF</code> by default. Depends on <code>JSON_BuildTests</code>.</p><asideclass=md-source-file><spanclass=md-source-file__fact><spanclass=md-icontitle="Last update"><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg></span><spanclass="git-revision-date-localized-plugingit-revision-date-localized-pluginLine truncated
</code></pre></div><p>However, the repository <ahref="https://github.com/nlohmann/json">https://github.com/nlohmann/json</a> download size is quite large.</p></div><h2id=cmake-options>CMake Options<aclass=headerlinkhref=#cmake-optionstitle="Permanent link">¶</a></h2><h3id=json_buildtests><code>JSON_BuildTests</code><aclass=headerlinkhref=#json_buildteststitle="Permanent link">¶</a></h3><p>Build the unit tests when <ahref="https://cmake.org/cmake/help/latest/command/enable_testing.html"><code>BUILD_TESTING</code></a> is enabled. This option is <code>ON</code> by default if the library's CMake project is the top project. That is, when integrating the library as described above, the test suite is not built unless explicitly switched on with this option.</p><h3id=json_ci><code>JSON_CI</code><aclass=headerlinkhref=#json_cititle="Permanent link">¶</a></h3><p>Enable <abbrtitle="Continuous Integration">CI</abbr> build targets. The exact targets are used during the several <abbrtitle="Continuous Integration">CI</abbr> steps and are subject to change without notice. This option is <code>OFF</code> by default.</p><h3id=json_diagnostics><code>JSON_Diagnostics</code><aclass=headerlinkhref=#json_diagnosticstitle="Permanent link">¶</a></h3><p>Enable <ahref=../../home/exceptions/#extended-diagnostic-messages>extended diagnostic messages</a> by defining macro <ahref=../../api/macros/json_diagnostics/><code>JSON_DIAGNOSTICS</code></a>. This option is <code>OFF</code> by default.</p><h3id=json_diagnostic_positions><code>JSON_Diagnostic_Positions</code><aclass=headerlinkhref=#json_diagnostic_positionstitle="Permanent link">¶</a></h3><p>Enable position diagnostics by defining macro <ahref=../../api/macros/json_diagnostic_positions/><code>JSON_DIAGNOSTIC_POSITIONS</code></a>. This option is <code>OFF</code> by default.</p><h3id=json_disableenumserialization><code>JSON_DisableEnumSerialization</code><aclass=headerlinkhref=#json_disableenumserializationtitle="Permanent link">¶</a></h3><p>Disable default <code>enum</code> serialization by defining the macro <ahref=../../api/macros/json_disable_enum_serialization/><code>JSON_DISABLE_ENUM_SERIALIZATION</code></a>. This option is <code>OFF</code> by default.</p><h3id=json_fasttests><code>JSON_FastTests</code><aclass=headerlinkhref=#json_fastteststitle="Permanent link">¶</a></h3><p>Skip expensive/slow test suites. This option is <code>OFF</code> by default. Depends on <code>JSON_BuildTests</code>.</p><h3id=json_globaludls><code>JSON_GlobalUDLs</code><aclass=headerlinkhref=#json_globaludlstitle="Permanent link">¶</a></h3><p>Place user-defined string literals in the global namespace by defining the macro <ahref=../../api/macros/json_use_global_udls/><code>JSON_USE_GLOBAL_UDLS</code></a>. This option is <code>OFF</code> by default.</p><h3id=json_implicitconversions><code>JSON_ImplicitConversions</code><aclass=headerlinkhref=#json_implicitconversionstitle="Permanent link">¶</a></h3><p>Enable implicit conversions by defining macro <ahref=../../api/macros/json_use_implicit_conversions/><code>JSON_USE_IMPLICIT_CONVERSIONS</code></a>. This option is <code>ON</code> by default.</p><h3id=json_install><code>JSON_Install</code><aclass=headerlinkhref=#json_installtitle="Permanent link">¶</a></h3><p>Install CMake targets during install step. This option is <code>ON</code> by default if the library's CMake project is the top project.</p><h3id=json_legacydiscardedvaluecomparison><code>JSON_LegacyDiscardedValueComparison</code><aclass=headerlinkhref=#json_legacydiscardedvaluecomparisontitle="Permanent link">¶</a></h3><p>Enable the (incorrect) legacy comparison behavior of discarded <abbrtitle="JavaScript Object Notation">JSON</abbr> values by defining macro <ahref=../../api/macros/json_use_legacy_discarded_value_comparison/><code>JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON</code></a>. This option is <code>OFF</code> by default.</p><h3id=json_multipleheaders><code>JSON_MultipleHeaders</code><aclass=headerlinkhref=#json_multipleheaderstitle="Permanent link">¶</a></h3><p>Use non-amalgamated version of the library. This option is <code>OFF</code> by default.</p><h3id=json_systeminclude><code>JSON_SystemInclude</code><aclass=headerlinkhref=#json_systemincludetitle="Permanent link">¶</a></h3><p>Treat the library headers like system headers (i.e., adding <code>SYSTEM</code> to the <ahref="https://cmake.org/cmake/help/latest/command/target_include_directories.html"><code>target_include_directories</code></a> call) to checks for this library by tools like Clang-Tidy. This option is <code>OFF</code> by default.</p><h3id=json_valgrind><code>JSON_Valgrind</code><aclass=headerlinkhref=#json_valgrindtitle="Permanent link">¶</a></h3><p>Execute test suite with <ahref="https://valgrind.org">Valgrind</a>. This option is <code>OFF</code> by default.Line truncated
</code></pre></div></div></div></div></li></ul><h4id=json-pointers>JSON Pointers<aclass=headerlinkhref=#json-pointerstitle="Permanent link">¶</a></h4><ul><li><p>Comparing JSON Pointers with strings via <ahref=../../api/json_pointer/operator_eq/><code>operator==</code></a> and <ahref=../../api/json_pointer/operator_ne/><code>operator!=</code></a> is deprecated since 3.11.2. To compare a <ahref=../../api/json_pointer/><code>json_pointer</code></a><code>p</code> with a string <code>s</code>, convert <code>s</code> to a <code>json_pointer</code> first and use <ahref=../../api/json_pointer/operator_eq/><code>json_pointer::operator==</code></a> or <ahref=../../api/json_pointer/operator_ne/><code>json_pointer::operator!=</code></a>.</p><divclass="tabbed-set tabbed-alternate"data-tabs=3:2><inputchecked=checkedid=__tabbed_3_1name=__tabbed_3type=radio><inputid=__tabbed_3_2name=__tabbed_3type=radio><divclass=tabbed-labels><labelfor=__tabbed_3_1>Deprecated</label><labelfor=__tabbed_3_2>Future-proof</label></div><divclass=tabbed-content><divclass=tabbed-block><divclass=highlight><pre><span></span><code><spanclass=n>nlohmann</span><spanclass=o>::</span><spanclass=n>json</span><spanclass=o>::</span><spanclass=n>json_pointer</span><spanclass=w></span><spanclass=n>lhs</span><spanclass=p>(</span><spanclass=s>"/foo/bar/1"</span><spanclass=p>);</span>
</code></pre></div></div></div></div></li></ul><h4id=json-pointers><abbrtitle="JavaScript Object Notation">JSON</abbr> Pointers<aclass=headerlinkhref=#json-pointerstitle="Permanent link">¶</a></h4><ul><li><p>Comparing <abbrtitle="JavaScript Object Notation">JSON</abbr> Pointers with strings via <ahref=../../api/json_pointer/operator_eq/><code>operator==</code></a> and <ahref=../../api/json_pointer/operator_ne/><code>operator!=</code></a> is deprecated since 3.11.2. To compare a <ahref=../../api/json_pointer/><code>json_pointer</code></a><code>p</code> with a string <code>s</code>, convert <code>s</code> to a <code>json_pointer</code> first and use <ahref=../../api/json_pointer/operator_eq/><code>json_pointer::operator==</code></a> or <ahref=../../api/json_pointer/operator_ne/><code>json_pointer::operator!=</code></a>.</p><divclass="tabbed-set tabbed-alternate"data-tabs=3:2><inputchecked=checkedid=__tabbed_3_1name=__tabbed_3type=radio><inputid=__tabbed_3_2name=__tabbed_3type=radio><divclass=tabbed-labels><labelfor=__tabbed_3_1>Deprecated</label><labelfor=__tabbed_3_2>Future-proof</label></div><divclass=tabbed-content><divclass=tabbed-block><divclass=highlight><pre><span></span><code><spanclass=n>nlohmann</span><spanclass=o>::</span><spanclass=n>json</span><spanclass=o>::</span><spanclass=n>json_pointer</span><spanclass=w></span><spanclass=n>lhs</span><spanclass=p>(</span><spanclass=s>"/foo/bar/1"</span><spanclass=p>);</span>
</code></pre></div></div></div></div></li><li><p>The implicit conversion from JSON Pointers to string (<ahref=../../api/json_pointer/operator_string_t/><code>json_pointer::operator string_t</code></a>) is deprecated since 3.11.0. Use <ahref=../../api/json_pointer/to_string/><code>json_pointer::to_string</code></a> instead.</p><divclass="tabbed-set tabbed-alternate"data-tabs=4:2><inputchecked=checkedid=__tabbed_4_1name=__tabbed_4type=radio><inputid=__tabbed_4_2name=__tabbed_4type=radio><divclass=tabbed-labels><labelfor=__tabbed_4_1>Deprecated</label><labelfor=__tabbed_4_2>Future-proof</label></div><divclass=tabbed-content><divclass=tabbed-block><divclass=highlight><pre><span></span><code><spanclass=n>nlohmann</span><spanclass=o>::</span><spanclass=n>json</span><spanclass=o>::</span><spanclass=n>json_pointer</span><spanclass=w></span><spanclass=n>ptr</span><spanclass=p>(</span><spanclass=s>"/foo/bar/1"</span><spanclass=p>);</span>
</code></pre></div></div></div></div></li><li><p>The implicit conversion from <abbrtitle="JavaScript Object Notation">JSON</abbr> Pointers to string (<ahref=../../api/json_pointer/operator_string_t/><code>json_pointer::operator string_t</code></a>) is deprecated since 3.11.0. Use <ahref=../../api/json_pointer/to_string/><code>json_pointer::to_string</code></a> instead.</p><divclass="tabbed-set tabbed-alternate"data-tabs=4:2><inputchecked=checkedid=__tabbed_4_1name=__tabbed_4type=radio><inputid=__tabbed_4_2name=__tabbed_4type=radio><divclass=tabbed-labels><labelfor=__tabbed_4_1>Deprecated</label><labelfor=__tabbed_4_2>Future-proof</label></div><divclass=tabbed-content><divclass=tabbed-block><divclass=highlight><pre><span></span><code><spanclass=n>nlohmann</span><spanclass=o>::</span><spanclass=n>json</span><spanclass=o>::</span><spanclass=n>json_pointer</span><spanclass=w></span><spanclass=n>ptr</span><spanclass=p>(</span><spanclass=s>"/foo/bar/1"</span><spanclass=p>);</span>
</code></pre></div><p>The header can be used directly in your code or via CMake.</p><detailsclass=example><summary>Example: Raw compilation</summary><ol><li><p>Create the following file:</p><divclass=highlight><spanclass=filename>example.cpp</span><pre><span></span><code><spanclass=cp>#include</span><spanclass=w></span><spanclass=cpf><nlohmann/json.hpp></span>
</code></pre></div></li><li><p>Install the package:</p><divclass=highlight><pre><span></span><code>brew<spanclass=w></span>install<spanclass=w></span>nlohmann-json
</code></pre></div></li><li><p>Compile the code and pass the Homebrew prefix to CMake to find installed packages via <codeclass=highlight><spanclass=err>find_package</span></code>:</p><divclass=highlight><pre><span></span><code><spanclass=nv>CMAKE_PREFIX_PATH</span><spanclass=o>=</span><spanclass=k>$(</span>brew<spanclass=w></span>--prefix<spanclass=k>)</span><spanclass=w></span>cmake<spanclass=w></span>-S<spanclass=w></span>.<spanclass=w></span>-B<spanclass=w></span>build
</code></pre></div><p>Please see the Meson project for any issues regarding the packaging.</p><p>The provided <code>meson.build</code> can also be used as an alternative to CMake for installing <code>nlohmann_json</code> system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the <code>nlohmann_json</code> pkg-config dependency. In Meson, it is preferred to use the <ahref=https://mesonbuild.com/Reference-manual.html#dependency><code>dependency()</code></a> object with a subproject fallback, rather than using the subproject directly.</p><detailsclass=example><summary>Example: Wrap</summary><ol><li><p>Create the following files:</p><divclass=highlight><spanclass=filename>meson.build</span><pre><span></span><code><spanclass=na>project('json_example', 'cpp',</span>
</code></pre></div><p>Please see the Meson project for any issues regarding the packaging.</p><p>The provided <code>meson.build</code> can also be used as an alternative to CMake for installing <code>nlohmann_json</code> system-wide in which case a pkg-config file is installed. To use it, have your build system require the <code>nlohmann_json</code> pkg-config dependency. In Meson, it is preferred to use the <ahref="https://mesonbuild.com/Reference-manual.html#dependency"><code>dependency()</code></a> object with a subproject fallback, rather than using the subproject directly.</p><detailsclass=example><summary>Example: Wrap</summary><ol><li><p>Create the following files:</p><divclass=highlight><spanclass=filename>meson.build</span><pre><span></span><code><spanclass=na>project('json_example', 'cpp',</span>
</code></pre></div><p>Please see the <ahref=https://github.com/spack/spack>Spack project</a> for any issues regarding the packaging.</p><detailsclass=example><summary>Example</summary><ol><li><p>Create the following files:</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>cmake_minimum_required</span><spanclass=p>(</span><spanclass=s>VERSION</span><spanclass=w></span><spanclass=s>3.15</span><spanclass=p>)</span>
</code></pre></div><p>Please see the <ahref="https://github.com/spack/spack">Spack project</a> for any issues regarding the packaging.</p><detailsclass=example><summary>Example</summary><ol><li><p>Create the following files:</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>cmake_minimum_required</span><spanclass=p>(</span><spanclass=s>VERSION</span><spanclass=w></span><spanclass=s>3.15</span><spanclass=p>)</span>
</code></pre></div></li><li><p>Load the environment for your Spack-installed packages:</p><divclass=highlight><pre><span></span><code>spack<spanclass=w></span>load<spanclass=w></span>nlohmann-json
</code></pre></div></li><li><p>Build the project with CMake:</p><divclass=highlight><pre><span></span><code>cmake<spanclass=w></span>-S<spanclass=w></span>.<spanclass=w></span>-B<spanclass=w></span>build<spanclass=w></span>-DCMAKE_PREFIX_PATH<spanclass=o>=</span><spanclass=k>$(</span>spack<spanclass=w></span>location<spanclass=w></span>-i<spanclass=w></span>nlohmann-json<spanclass=k>)</span>
</code></pre></div><p>Please see the Hunter project for any issues regarding the packaging.</p><detailsclass=example><summary>Example</summary><ol><li><p>Create the following files:</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>cmake_minimum_required</span><spanclass=p>(</span><spanclass=s>VERSION</span><spanclass=w></span><spanclass=s>3.15</span><spanclass=p>)</span>
</code></pre></div></li><li><p>Build the project with CMake:</p><divclass=highlight><pre><span></span><code>cmake<spanclass=w></span>-S<spanclass=w></span>.<spanclass=w></span>-B<spanclass=w></span>build
</code></pre></div><p>and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging.</p><detailsclass=example><summary>Example</summary><ol><li><p>Create the following files:</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>cmake_minimum_required</span><spanclass=p>(</span><spanclass=s>VERSION</span><spanclass=w></span><spanclass=s>3.15</span><spanclass=p>)</span>
</code></pre></div><p>A specific version can be installed with <code>cget install nlohmann/json@v3.11.3</code>. Also, the multiple header version can be installed by adding the <code>-DJSON_MultipleHeaders=ON</code> flag (i.e., <code>cget install nlohmann/json -DJSON_MultipleHeaders=ON</code>).</p><detailsclass=example><summary>Example</summary><ol><li><p>Create the following files:</p><divclass=highlight><spanclass=filename>CMakeLists.txt</span><pre><span></span><code><spanclass=nb>cmake_minimum_required</span><spanclass=p>(</span><spanclass=s>VERSION</span><spanclass=w></span><spanclass=s>3.15</span><spanclass=p>)</span>
</code></pre></div></li><li><p>Install the library</p><divclass=highlight><pre><span></span><code>cget<spanclass=w></span>install<spanclass=w></span>nlohmann/json
</code></pre></div><detailsclass=example><summary>Example</summary><p>Probably the easiest way to use NuGet packages is through Visual Studio graphical interface. Just right-click on a project (any C++ project would do) in “Solution Explorer” and select “Manage NuGet Packages…”</p><p><imgaltsrc=../nuget/nuget-search-package.png></p><p>Now you can click on “Browse” tab and find the package you like to install.</p><p><imgaltsrc=../nuget/nuget-select-package.png></p><p>Most of the packages in NuGet gallery are .NET packages and would not be useful in a C++ project. Microsoft recommends adding “native” and “nativepackage” tags to C++ NuGet packages to distinguish them, but even adding “native” to search query would still show many .NET-only packages in the list.</p><p>Nevertheless, after finding the package you want, just click on “Install” button and accept confirmation dialogs. After the package is successfully added to the projects, you should be able to just build and execute the project without the need for making any more changes to build settings.</p><divclass="admonition note"><pclass=admonition-title>Note</p><p>A few notes:</p><ul><li>NuGet packages are installed per project and not system-wide. The header and binaries for the package are only available to the project it is added to, and not other projects (obviously unless we add the package to those projects as well)</li><li>One of the many great things about your elegant work is that it is a header-only library, which makes deployment very straightforward. In case of libraries which need binary deployment (<code>.lib</code>, <code>.dll</code> and <code>.pdb</code> for debug info) the different binaries for each supported compiler version must be added to the NuGet package. Some library creators cram binary versions for all supported Visual C++ compiler versions in the same package, so a single package will support all compilers. Some others create a different package for each compiler version (and you usually see things like “v140” or “vc141” in package name to clarify which VC++ compiler this package supports).</li><li>Packages can have dependency to other packages, and in this case, NuGet will install all dependencies as well as the requested package recursively.</li></ul></div><p><strong>What happens behind the scenes</strong></p><p>After you add a NuGet package, three changes occur in the project source directory. Of course, we could make these changes manually instead of using GUI:</p><p><imgaltsrc=../nuget/nuget-project-changes.png></p><ol><li><p>A <code>packages.config</code> file will be created (or updated to include the package name if one such file already exists). This file contains a list of the packages required by this project (name and minimum version) and must be added to the project source code repository, so if you move the source code to a new machine, MSBuild/NuGet knows which packages it has to restore (which it does automatically before each build).</p><divclass=highlight><pre><span></span><code><spanclass=cp><?xml version="1.0" encoding="utf-8"?></span>
</code></pre></div><detailsclass=example><summary>Example</summary><p>Probably the easiest way to use NuGet packages is through Visual Studio graphical interface. Just right-click on a project (any C++ project would do) in “Solution Explorer” and select “Manage NuGet Packages…”</p><p><imgaltsrc=../nuget/nuget-search-package.png></p><p>Now you can click on “Browse” tab and find the package you like to install.</p><p><imgaltsrc=../nuget/nuget-select-package.png></p><p>Most of the packages in NuGet gallery are .NET packages and would not be useful in a C++ project. Microsoft recommends adding “native” and “nativepackage” tags to C++ NuGet packages to distinguish them, but even adding “native” to search query would still show many .NET-only packages in the list.</p><p>Nevertheless, after finding the package you want, click on “Install” button and accept confirmation dialogs. After the package is successfully added to the projects, you should be able to build and execute the project without the need for making any more changes to build settings.</p><divclass="admonition note"><pclass=admonition-title>Note</p><p>A few notes:</p><ul><li>NuGet packages are installed per project and not system-wide. The header and binaries for the package are only available to the project it is added to, and not other projects (obviously unless we add the package to those projects as well)</li><li>One of the many great things about your elegant work is that it is a header-only library, which makes deployment very straightforward. In case of libraries which need binary deployment (<code>.lib</code>, <code>.dll</code> and <code>.pdb</code> for debug info) the different binaries for each supported compiler version must be added to the NuGet package. Some library creators cram binary versions for all supported Visual C++ compiler versions in the same package, so a single package will support all compilers. Some others create a different package for each compiler version (and you usually see things like “v140” or “vc141” in package name to clarify which VC++ compiler this package supports).</li><li>Packages can have dependency to other packages, and in this case, NuGet will install all dependencies as well as the requested package recursively.</li></ul></div><p><strong>What happens behind the scenes</strong></p><p>After you add a NuGet package, three changes occur in the project source directory. Of course, we could make these changes manually instead of using GUI:</p><p><imgaltsrc=../nuget/nuget-project-changes.png></p><ol><li><p>A <code>packages.config</code> file will be created (or updated to include the package name if one such file already exists). This file contains a list of the packages required by this project (name and minimum version) and must be added to the project source code repository, so if you move the source code to a new machine, MSBuild/NuGet knows which packages it has to restore (which it does automatically before each build).</p><divclass=highlight><pre><span></span><code><spanclass=cp><?xml version="1.0" encoding="utf-8"?></span>
</code></pre></div><p>For libraries with binary files, we will need to add <code>.lib</code> files to linker inputs and add settings to copy <code>.dll</code> and other redistributable files to output directory, if needed.</p><p>There are other changes to the makefile as well:</p><ul><li><p>Lines 165-167 add the <code>packages.config</code> as one of project files (so it is shown in Solution Explorer tree view). It is added as None (no build action) and removing it wouldn’t affect build.</p></li><li><p>Lines 172-177 check to ensure the required packages are present. This will display a build error if package directory is empty (for example when NuGet cannot restore packages because Internet connection is down). Again, if you omit this section, the only change in build would be a more cryptic error message if build fails.</p></li></ul><divclass="admonition note"><pclass=admonition-title>Note</p><p>Changes to .vcxproj makefile should also be added to project source code repository.</p></div></li></ol><p>As you can see, the mechanism NuGet uses to modify project settings is through MSBuild makefiles, so using NuGet with other build systems and compilers (like CMake) as a dependency manager is either impossible or more problematic than useful.</p></details><p>Please refer to <ahref=https://github.com/nlohmann/json/issues/1132#issuecomment-452250255>this extensive description</a> for more information.</p><h2id=conda>Conda<aclass=headerlinkhref=#condatitle="Permanent link">¶</a></h2><p>If you are using <ahref=https://conda.io/>conda</a>, you can use the package <ahref=https://github.com/conda-forge/nlohmann_json-feedstock>nlohmann_json</a> from <ahref=https://conda-forge.org>conda-forge</a> executing <code>conda install -c conda-forge nlohmann_json</code>. Please file issues <ahref=https://github.com/conda-forge/nlohmann_json-feedstock/issues>here</a>.</p><h2id=msys2>MSYS2<aclass=headerlinkhref=#msys2title="Permanent link">¶</a></h2><p>If you are using <ahref=http://www.msys2.org/>MSYS2</a>, you can use the <ahref=https://packages.msys2.org/base/mingw-w64-nlohmann-json>mingw-w64-nlohmann-json</a> package, just type <code>pacman -S mingw-w64-i686-nlohmann-json</code> or <code>pacman -S mingw-w64-x86_64-nlohmann-json</code> for installation. Please file issues <ahref="https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D">here</a> if you experience problems with the packages.</p><p><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1a6.887 6.887 0 0 0 0 9.8c2.73 2.7 7.15 2.7 9.88 0 1.36-1.35 2.04-2.92 2.04-4.9h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58a8.987 8.987 0 0 1 12.65 0L21 3zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8z"/></svg></span> The <ahref=https://packages.msys2.org/base/mingw-w64-nlohmann-json>package</a> is updated automatically.</p><h2id=macports>MacPorts<aclass=headerlinkhref=#macportstitle="Permanent link">¶</a></h2><divclass="admonition abstract"><pclass=admonition-title>Summary</p><p>port: <ahref=https://ports.macports.org/port/nlohmann-json/><strong><code>nlohmann-json</code></strong></a></p><ul><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M7.75 6.5a1.25 1.25 0 1 0 0 2.5 1.25 1.25 0 0 0 0-2.5"/><pathd="M2.5 1h8.44a1.5 1.5 0 0 1 1.06.44l10.25 10.25a1.5 1.5 0 0 1 0 2.12l-8.44 8.44a1.5 1.5 0 0 1-2.12 0L1.44 12A1.5 1.5 0 0 1 1 10.94V2.5A1.5 1.5 0 0 1 2.5 1m0 1.5v8.44l10.25 10.25 8.44-8.44L10.94 2.5Z"/></svg></span> Availalbe versions: current version</li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M20.322.75h1.176a1.75 1.75 0 0 1 1.75 1.749v1.177a10.75 10.75 0 0 1-2.925 7.374l-1.228 1.304a24 24 0 0 1-1.596 1.542v5.038c0 .615-.323 1.184-.85 1.5l-4.514 2.709a.75.75 0 0 1-1.12-.488l-.963-4.572a1.3 1.3 0 0 1-.14-.129L8.04 15.96l-1.994-1.873a1.3 1.3 0 0 1-.129-.14l-4.571-.963a.75.75 0 0 1-.49-1.12l2.71-4.514c.316-.527.885-.85 1.5-.85h5.037a24 24 0 0 1 1.542-1.594l1.304-1.23A10.75 10.75 0 0 1 20.321.75Zm-6.344 4.018v-.001l-1.304 1.23a22.3 22.3 0 0 0-3.255 3.851l-2.193 3.29 1.859 1.744.034.034 1.743 1.858 3.288-2.192a22.3 22.3 0 0 0 3.854-3.257l1.228-1.303a9.25 9.25 0 0 0 2.517-6.346V2.5a.25.25 0 0 0-.25-.25h-1.177a9.25 9.25 0 0 0-6.344 2.518M6.5 21c-1.209 1.209-3.901 1.445-4.743 1.49a.24.24 0 0 1-.18-.067.24.24 0 0 1-.067-.18c.045-.842.281-3.534 1.49-4.743.9-.9 2.6-.9 3.5 0s.9 2.6 0 3.5m-.592-8.588L8.17 9.017q.346-.519.717-1.017H5.066a.25.25 0 0 0-.214.121l-2.167 3.612ZM16 15.112q-.5.372-1.018.718l-3.393 2.262.678 3.223 3.612-2.167a.25.25 0 0 0 .121-.214ZM17.5 8a1.5 1.5 0 1 1-3.001-.001A1.5 1.5 0 0 1 17.5 8"/></svg></span> The port is updated with every release.</li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M33a220012-2h9.982a22001Line truncated
</code></pre></div><p>to install the <ahref=https://ports.macports.org/port/nlohmann-json/>nlohmann-json</a> package.</p><detailsclass=example><summary>Example: Raw compilation</summary><ol><li><p>Create the following file:</p><divclass=highlight><spanclass=filename>example.cpp</span><pre><span></span><code><spanclass=cp>#include</span><spanclass=w></span><spanclass=cpf><nlohmann/json.hpp></span>
</code></pre></div><p>For libraries with binary files, we will need to add <code>.lib</code> files to linker inputs and add settings to copy <code>.dll</code> and other redistributable files to output directory, if needed.</p><p>There are other changes to the makefile as well:</p><ul><li><p>Lines 165-167 add the <code>packages.config</code> as one of project files (so it is shown in Solution Explorer tree view). It is added as None (no build action) and removing it wouldn’t affect build.</p></li><li><p>Lines 172-177 check to ensure the required packages are present. This will display a build error if package directory is empty (for example when NuGet cannot restore packages because Internet connection is down). Again, if you omit this section, the only change in build would be a more cryptic error message if build fails.</p></li></ul><divclass="admonition note"><pclass=admonition-title>Note</p><p>Changes to .vcxproj makefile should also be added to project source code repository.</p></div></li></ol><p>As you can see, the mechanism NuGet uses to modify project settings is through MSBuild makefiles, so using NuGet with other build systems and compilers (like CMake) as a dependency manager is either impossible or more problematic than useful.</p></details><p>Please refer to <ahref="https://github.com/nlohmann/json/issues/1132#issuecomment-452250255">this extensive description</a> for more information.</p><h2id=conda>Conda<aclass=headerlinkhref=#condatitle="Permanent link">¶</a></h2><divclass="admonition abstract"><pclass=admonition-title>Summary</p><p>package: <ahref="https://anaconda.org/conda-forge/nlohmann_json"><strong><code>nlohmann_json</code></strong></a></p><ul><li><imgaltsrc="../../assets/external/img.shields.io/conda/v/conda-forge/nlohmann_json.svg"></li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M7.75 6.5a1.25 1.25 0 1 0 0 2.5 1.25 1.25 0 0 0 0-2.5"/><pathd="M2.5 1h8.44a1.5 1.5 0 0 1 1.06.44l10.25 10.25a1.5 1.5 0 0 1 0 2.12l-8.44 8.44a1.5 1.5 0 0 1-2.12 0L1.44 12A1.5 1.5 0 0 1 1 10.94V2.5A1.5 1.5 0 0 1 2.5 1m0 1.5v8.44l10.25 10.25 8.44-8.44L10.94 2.5Z"/></svg></span> Availalbe versions: current and previous versions</li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M20.322.75h1.176a1.75 1.75 0 0 1 1.75 1.749v1.177a10.75 10.75 0 0 1-2.925 7.374l-1.228 1.304a24 24 0 0 1-1.596 1.542v5.038c0 .615-.323 1.184-.85 1.5l-4.514 2.709a.75.75 0 0 1-1.12-.488l-.963-4.572a1.3 1.3 0 0 1-.14-.129L8.04 15.96l-1.994-1.873a1.3 1.3 0 0 1-.129-.14l-4.571-.963a.75.75 0 0 1-.49-1.12l2.71-4.514c.316-.527.885-.85 1.5-.85h5.037a24 24 0 0 1 1.542-1.594l1.304-1.23A10.75 10.75 0 0 1 20.321.75Zm-6.344 4.018v-.001l-1.304 1.23a22.3 22.3 0 0 0-3.255 3.851l-2.193 3.29 1.859 1.744.034.034 1.743 1.858 3.288-2.192a22.3 22.3 0 0 0 3.854-3.257l1.228-1.303a9.25 9.25 0 0 0 2.517-6.346V2.5a.25.25 0 0 0-.25-.25h-1.177a9.25 9.25 0 0 0-6.344 2.518M6.5 21c-1.209 1.209-3.901 1.445-4.743 1.49a.24.24 0 0 1-.18-.067.24.24 0 0 1-.067-.18c.045-.842.281-3.534 1.49-4.743.9-.9 2.6-.9 3.5 0s.9 2.6 0 3.5m-.592-8.588L8.17 9.017q.346-.519.717-1.017H5.066a.25.25 0 0 0-.214.121l-2.167 3.612ZM16 15.112q-.5.372-1.018.718l-3.393 2.262.678 3.223 3.612-2.167a.25.25 0 0 0 .121-.214ZM17.5 8a1.5 1.5 0 1 1-3.001-.001A1.5 1.5 0 0 1 17.5 8"/></svg></span> The package is updated with every release.</li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M3 3a2 2 0 0 1 2-2h9.982a2 2 0 0 1 1.414.586l4.018 4.018A2 2 0 0 1 21 7.018V21a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v18a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5V8.5h-4a2 2 0 0 1-2-2v-4Zm10 0v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 0-.146-.336l-4.018-4.018A.5.5 0 0 0 15 2.5"/></svg></span> File issues at the <ahref="https://github.com/conda-forge/nlohmann_json-feedstock/issues">feedstock's issue tracker</a></li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M10.97 8.265a1.45 1.45 0 0 0-.487.57.75.75 0 0 1-1.341-.67c.2-.402.513-.826.997-1.148C10.627 6.69 11.244 6.5 12 6.5c.658 0 1.369.195 1.934.619a2.45 2.45 0 0 1 1.004 2.006c0 1.033-.513 1.72-1.027 2.215-.19.183-.399.358-.579.508l-.147.123a4 4 0 0 0-.435.409v1.37a.75.75 0 1 1-1.5 0v-1.473c0-.237.067-.504.247-.736.22-.28.486-.517.718-.714l.183-.153.001-.001c.172-.143.324-.27.47-.412.368-.355.569-.676.569-1.136a.95.95 0 0 0-.404-.806C12.766 8.118 12.384 8 12 8c-.494 0-.814.121-1.03.265M13 17a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/><pathd="M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1M2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12"/></svg></span><ahref="https://docs.conda.io/projects/conda/en/stable/user-guide/getting-started.html">Conda documentation</a></li></ul></div><p>If you are using <ahref="https://conda.io/">conda</a>, you can use the package <ahref="https://anaconda.org/conda-fLine truncated
</code></pre></div><detailsclass=example><summary>Example</summary><ol><li><p>Create the following file:</p><divclass=highlight><spanclass=filename>example.cpp</span><pre><span></span><code><spanclass=cp>#include</span><spanclass=w></span><spanclass=cpf><nlohmann/json.hpp></span>
</code></pre></div></li><li><p>Create and activate an anvironment "json`:</p><divclass=highlight><pre><span></span><code>conda<spanclass=w></span>create<spanclass=w></span>-n<spanclass=w></span>json
</code></pre></div></li><li><p>Install the package:</p><divclass=highlight><pre><span></span><code>conda<spanclass=w></span>install<spanclass=w></span>-c<spanclass=w></span>conda-forge<spanclass=w></span>nlohmann_json
</code></pre></div></li><li><p>Build the code:</p><divclass=highlight><pre><span></span><code>g++<spanclass=w></span>-std<spanclass=o>=</span>c++11<spanclass=w></span>-I<spanclass=k>$(</span>conda<spanclass=w></span>info<spanclass=w></span>--base<spanclass=k>)</span>/envs/json/include<spanclass=w></span>example.cpp<spanclass=w></span>-o<spanclass=w></span>example
</code></pre></div><p>to install the <ahref="https://ports.macports.org/port/nlohmann-json/">nlohmann-json</a> package.</p><detailsclass=example><summary>Example: Raw compilation</summary><ol><li><p>Create the following file:</p><divclass=highlight><spanclass=filename>example.cpp</span><pre><span></span><code><spanclass=cp>#include</span><spanclass=w></span><spanclass=cpf><nlohmann/json.hpp></span>
</code></pre></div></li><li><p>Install the package:</p><divclass=highlight><pre><span></span><code>sudo<spanclass=w></span>port<spanclass=w></span>install<spanclass=w></span>nlohmann-json
</code></pre></div></li><li><p>Compile the code:</p><divclass=highlight><pre><span></span><code>cmake<spanclass=w></span>-S<spanclass=w></span>.<spanclass=w></span>-B<spanclass=w></span>build
</code></pre></div></li></ol></details><h2id=build2>build2<aclass=headerlinkhref=#build2title="Permanent link">¶</a></h2><p>If you are using <ahref=https://build2.org><code>build2</code></a>, you can use the <ahref=https://cppget.org/nlohmann-json><code>nlohmann-json</code></a> package from the public repository <ahref=http://cppget.org>http://cppget.org</a> or directly from the <ahref=https://github.com/build2-packaging/nlohmann-json>package's sources repository</a>. In your project's <code>manifest</code> file, just add <code>depends: nlohmann-json</code> (probably with some <ahref=https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps>version constraints</a>). If you are not familiar with using dependencies in <code>build2</code>, <ahref=https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml>please read this introduction</a>. Please file issues <ahref=https://github.com/build2-packaging/nlohmann-json>here</a> if you experience problems with the packages.</p><p><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1a6.887 6.887 0 0 0 0 9.8c2.73 2.7 7.15 2.7 9.88 0 1.36-1.35 2.04-2.92 2.04-4.9h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58a8.987 8.987 0 0 1 12.65 0L21 3zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8z"/></svg></span> The <ahref=https://cppget.org/nlohmann-json>package</a> is updated automatically.</p><h2id=wsjcpp>wsjcpp<aclass=headerlinkhref=#wsjcpptitle="Permanent link">¶</a></h2><p>If you are using <ahref=http://wsjcpp.org><code>wsjcpp</code></a>, you can use the command <code>wsjcpp install "https://github.com/nlohmann/json:develop"</code> to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch.</p><p><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1a6.887 6.887 0 0 0 0 9.8c2.73 2.7 7.15 2.7 9.88 0 1.36-1.35 2.04-2.92 2.04-4.9h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58a8.987 8.987 0 0 1 12.65 0L21 3zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8z"/></svg></span> wsjcpp reads directly from the <ahref=https://github.com/nlohmann/json>GitHub repository</a> and is always up-to-date.</p><h2id=cpmcmake>CPM.cmake<aclass=headerlinkhref=#cpmcmaketitle="Permanent link">¶</a></h2><divclass="admonition abstract"><pclass=admonition-title>Summary</p><p>package: <strong><code>gh:nlohmann/json</code></strong></p><ul><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M7.75 6.5a1.25 1.25 0 1 0 0 2.5 1.25 1.25 0 0 0 0-2.5"/><pathd="M2.5 1h8.44a1.5 1.5 0 0 1 1.06.44l10.25 10.25a1.5 1.5 0 0 1 0 2.12l-8.44 8.44a1.5 1.5 0 0 1-2.12 0L1.44 12A1.5 1.5 0 0 1 1 10.94V2.5A1.5 1.5 0 0 1 2.5 1m0 1.5v8.44l10.25 10.25 8.44-8.44L10.94 2.5Z"/></svg></span> Availalbe versions: current and previous versions</li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M20.322.75h1.176a1.75 1.75 0 0 1 1.75 1.749v1.177a10.75 10.75 0 0 1-2.925 7.374l-1.228 1.304a24 24 0 0 1-1.596 1.542v5.038c0 .615-.323 1.184-.85 1.5l-4.514 2.709a.75.75 0 0 1-1.12-.488l-.963-4.572a1.3 1.3 0 0 1-.14-.129L8.04 15.96l-1.994-1.873a1.3 1.3 0 0 1-.129-.14l-4.571-.963a.75.75 0 0 1-.49-1.12l2.71-4.514c.316-.527.885-.85 1.5-.85h5.037a24 24 0 0 1 1.542-1.594l1.304-1.23A10.75 10.75 0 0 1 20.321.75Zm-6.344 4.018v-.001l-1.304 1.23a22.3 22.3 0 0 0-3.255 3.851l-2.193 3.29 1.859 1.744.034.034 1.743 1.858 3.288-2.192a22.3 22.3 0 0 0 3.854-3.257l1.228-1.303a9.25 9.25 0 0 0 2.517-6.346V2.5a.25.25 0 0 0-.25-.25h-1.177a9.25 9.25 0 0 0-6.344 2.518M6.5 21c-1.209 1.209-3.901 1.445-4.743 1.49a.24.24 0 0 1-.18-.067.24.24 0 0 1-.067-.18c.045-.842.281-3.534 1.49-4.743.9-.9 2.6-.9 3.5 0s.9 2.6 0 3.5m-.592-8.588L8.17 9.017q.346-.519.717-1.017H5.066a.25.25 0 0 0-.214.121l-2.167 3.612ZM16 15.112q-.5.372-1.018.718l-3.393 2.262.678 3.223 3.612-2.167a.25.25 0 0 0 .121-.214ZM17.5 8a1.5 1.5 0 1 1-3.001-.001A1.5 1.5 0 0 1 17.5 8"/></svg></span> The package is updated with every release.</li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M3 3a2 2 0 0 1 2-2h9.982a2 2 0 0 1 1.414.586l4.018 4.018A2 2 0 0 1 21 7.018V21a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v18a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5V8.5h-4a2 2 0 0 1-2-2v-4Zm10 0v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 0-.146-.336l-4.018-4.018A.5.5 0 0 0 15 2.5"/></svg></span> File issues at the <ahref=https://github.com/cpm-cmake/CPM.cmake/issues>CPM.cmake issue tracker</a></li><li><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M10.978.265a1.451.45000-.487.57.75.75001-1.341-.67c.2-.402.513-.826.997-1.148C10.6276.6911.2446.5126.5c.65801.369.1951.934.619a2.452.450011.0042.0Line truncated
</code></pre></div></li></ol></details><h2id=build2>build2<aclass=headerlinkhref=#build2title="Permanent link">¶</a></h2><p>If you are using <ahref="https://build2.org"><code>build2</code></a>, you can use the <ahref="https://cppget.org/nlohmann-json"><code>nlohmann-json</code></a> package from the public repository <ahref="http://cppget.org">http://cppget.org</a> or directly from the <ahref="https://github.com/build2-packaging/nlohmann-json">package's sources repository</a>. In your project's <code>manifest</code> file, add <code>depends: nlohmann-json</code> (probably with some <ahref="https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps">version constraints</a>). If you are not familiar with using dependencies in <code>build2</code>, <ahref="https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml">please read this introduction</a>. Please file issues <ahref="https://github.com/build2-packaging/nlohmann-json">here</a> if you experience problems with the packages.</p><p><spanclass=twemoji><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1a6.887 6.887 0 0 0 0 9.8c2.73 2.7 7.15 2.7 9.88 0 1.36-1.35 2.04-2.92 2.04-4.9h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58a8.987 8.987 0 0 1 12.65 0L21 3zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8z"/></svg></span> The <ahref="https://cppget.org/nlohmann-json">package</a> is updated automatically.</p><divclass=highlight><pre><span></span><code>bdep<spanclass=w></span>new<spanclass=w></span>-t<spanclass=w></span>exe<spanclass=w></span>-l<spanclass=w></span>c++
</code></pre></div><detailsclass=example><summary>Example</summary><ol><li><p>Create the following files:</p><divclass=highlight><spanclass=filename>example.cpp</span><pre><span></span><code><spanclass=cp>#include</span><spanclass=w></span><spanclass=cpf><nlohmann/json.hpp></span>
</code></pre></div><p>Users of the <ahref=../package_managers/#meson>Meson build system</a> will also be able to use a system-wide library, which will be found by <code>pkg-config</code>:</p><divclass=highlight><pre><span></span><code><spanclass=n>json</span><spanclass=w></span><spanclass=o>=</span><spanclass=w></span><spanclass=nb>dependency</span><spanclass=p>(</span><spanclass=s>'nlohmann_json'</span><spanclass=p>,</span><spanclass=w></span><spanclass=n>required</span><spanclass=p>:</span><spanclass=w></span><spanclass=kc>true</span><spanclass=p>)</span>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.