This commit is contained in:
nlohmann committed 2026-07-09 16:04:09 +00:00
1 parent a72084fa16
commit c9c3d3de86
308 files changed
+423 -309

No files matched your search

+2 -2
View File
@@ -19,7 +19,7 @@
<span class=k>return</span><span class=w> </span><span class=n>ret</span><span class=p>;</span>
</code></pre></div></p> <p>This overload is chosen if:</p> <ul> <li><code>ValueType</code> is not <code>basic_json</code>,</li> <li><code>json_serializer&lt;ValueType&gt;</code> has a <code>from_json()</code> method of the form <code>void from_json(const basic_json&amp;, ValueType&amp;)</code>, and</li> <li><code>json_serializer&lt;ValueType&gt;</code> does not have a <code>from_json()</code> method of the form <code>ValueType from_json(const basic_json&amp;)</code></li> </ul> <p>If the type is <strong>not</strong> <a href="https://en.cppreference.com/w/cpp/named_req/CopyConstructible">CopyConstructible</a> and <strong>not</strong> <a href="https://en.cppreference.com/w/cpp/named_req/DefaultConstructible">DefaultConstructible</a>, the value is converted by calling the <code>json_serializer&lt;ValueType&gt;</code> <code>from_json()</code> method.</p> <p>The function is then equivalent to executing <div class=highlight><pre><span></span><code><span class=k>return</span><span class=w> </span><span class=n>JSONSerializer</span><span class=o>&lt;</span><span class=n>ValueTypeCV</span><span class=o>&gt;::</span><span class=n>from_json</span><span class=p>(</span><span class=o>*</span><span class=k>this</span><span class=p>);</span>
</code></pre></div></p> <p>This overload is chosen if:</p> <ul> <li><code>ValueType</code> is not <code>basic_json</code> and</li> <li><code>json_serializer&lt;ValueType&gt;</code> has a <code>from_json()</code> method of the form <code>ValueType from_json(const basic_json&amp;)</code></li> </ul> <p>If <code>json_serializer&lt;ValueType&gt;</code> has both overloads of <code>from_json()</code>, the latter one is chosen.</p> </li> <li> <p>Overload for <code>basic_json</code> specializations. The function is equivalent to executing <div class=highlight><pre><span></span><code><span class=k>return</span><span class=w> </span><span class=o>*</span><span class=k>this</span><span class=p>;</span>
</code></pre></div></p> </li> <li> <p>Explicit pointer access to the internally stored <abbr title="JavaScript Object Notation">JSON</abbr> value. No copies are made.</p> </li> </ol> <h2 id=template-parameters>Template parameters<a class=headerlink href=#template-parameters title="Permanent link">&para;</a></h2> <dl> <dt><code>ValueType</code></dt> <dd>the value type to return</dd> <dt><code>BasicJsonType</code></dt> <dd>a specialization of <code>basic_json</code></dd> <dt><code>PointerType</code></dt> <dd>pointer type; must be a pointer to <a href=../array_t/ ><code>array_t</code></a>, <a href=../object_t/ ><code>object_t</code></a>, <a href=../string_t/ ><code>string_t</code></a>, <a href=../boolean_t/ ><code>boolean_t</code></a>, <a href=../number_integer_t/ ><code>number_integer_t</code></a>, or <a href=../number_unsigned_t/ ><code>number_unsigned_t</code></a>, <a href=../number_float_t/ ><code>number_float_t</code></a>, or <a href=../binary_t/ ><code>binary_t</code></a>. Other types will not compile.</dd> </dl> <h2 id=return-value>Return value<a class=headerlink href=#return-value title="Permanent link">&para;</a></h2> <ol> <li>copy of the <abbr title="JavaScript Object Notation">JSON</abbr> value, converted to <code>ValueType</code></li> <li>a copy of <code class=highlight><span class=o>*</span><span class=k>this</span></code>, converted into <code>BasicJsonType</code></li> <li>pointer to the internally stored <abbr title="JavaScript Object Notation">JSON</abbr> value if the requested pointer type fits to the <abbr title="JavaScript Object Notation">JSON</abbr> value; <code class=highlight><span class=nb>nullptr</span></code> otherwise</li> </ol> <h2 id=exceptions>Exceptions<a class=headerlink href=#exceptions title="Permanent link">&para;</a></h2> <p>Depends on what <code>json_serializer&lt;ValueType&gt;</code> <code>from_json()</code> method throws</p> <h2 id=complexity>Complexity<a class=headerlink href=#complexity title="Permanent link">&para;</a></h2> <p>Depends on the <code>json_serializer&lt;ValueType&gt;::from_json()</code> implementation for overloads (1) and (2); constant for overload (3).</p> <h2 id=notes>Notes<a class=headerlink href=#notes title="Permanent link">&para;</a></h2> <div class="admonition danger"> <p class=admonition-title>Undefined behavior for pointers</p> <p>Writing data to the pointee (overload 3) of the result yields an undefined state.</p> </div> <div class="admonition danger"> <p class=admonition-title>Undefined behavior for numeric conversions</p> <p>Conversions between numeric types are performed by the corresponding <code>from_json()</code> implementation using the target C++ type. When converting between numeric types, the library does not check whether the source value is representable by the target type.</p> <p>If the source value is outside the range of the target type, the behavior is the same as the corresponding C++ conversion. In particular, converting a floating-point value to an integer type that cannot represent the value results in undefined behavior.</p> <p>See <a href=../../../features/types/number_handling/#number-conversion>Number conversion</a> for more information.</p> </div> <h2 id=examples>Examples<a class=headerlink href=#examples title="Permanent link">&para;</a></h2> <details class=example> <summary>Example</summary> <p>The example below shows several conversions from <abbr title="JavaScript Object Notation">JSON</abbr> values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers, (2) A <abbr title="JavaScript Object Notation">JSON</abbr> array can be converted to a standard <code>std::vector&lt;short&gt;</code>, (3) A <abbr title="JavaScript Object Notation">JSON</abbr> object can be converted to C++ associative containers such as <code>std::unordered_map&lt;std::string, json&gt;</code>.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf>&lt;iostream&gt;</span>
</code></pre></div></p> </li> <li> <p>Explicit pointer access to the internally stored <abbr title="JavaScript Object Notation">JSON</abbr> value. No copies are made.</p> </li> </ol> <h2 id=template-parameters>Template parameters<a class=headerlink href=#template-parameters title="Permanent link">&para;</a></h2> <dl> <dt><code>ValueType</code></dt> <dd>the value type to return</dd> <dt><code>BasicJsonType</code></dt> <dd>a specialization of <code>basic_json</code></dd> <dt><code>PointerType</code></dt> <dd>pointer type; must be a pointer to <a href=../array_t/ ><code>array_t</code></a>, <a href=../object_t/ ><code>object_t</code></a>, <a href=../string_t/ ><code>string_t</code></a>, <a href=../boolean_t/ ><code>boolean_t</code></a>, <a href=../number_integer_t/ ><code>number_integer_t</code></a>, or <a href=../number_unsigned_t/ ><code>number_unsigned_t</code></a>, <a href=../number_float_t/ ><code>number_float_t</code></a>, or <a href=../binary_t/ ><code>binary_t</code></a>. Other types will not compile.</dd> </dl> <h2 id=return-value>Return value<a class=headerlink href=#return-value title="Permanent link">&para;</a></h2> <ol> <li>copy of the <abbr title="JavaScript Object Notation">JSON</abbr> value, converted to <code>ValueType</code></li> <li>a copy of <code class=highlight><span class=o>*</span><span class=k>this</span></code>, converted into <code>BasicJsonType</code></li> <li>pointer to the internally stored <abbr title="JavaScript Object Notation">JSON</abbr> value if the requested pointer type fits to the <abbr title="JavaScript Object Notation">JSON</abbr> value; <code class=highlight><span class=nb>nullptr</span></code> otherwise</li> </ol> <h2 id=exceptions>Exceptions<a class=headerlink href=#exceptions title="Permanent link">&para;</a></h2> <p>Depends on what <code>json_serializer&lt;ValueType&gt;</code> <code>from_json()</code> method throws</p> <h2 id=complexity>Complexity<a class=headerlink href=#complexity title="Permanent link">&para;</a></h2> <p>Depends on the <code>json_serializer&lt;ValueType&gt;::from_json()</code> implementation for overloads (1) and (2); constant for overload (3).</p> <h2 id=notes>Notes<a class=headerlink href=#notes title="Permanent link">&para;</a></h2> <div class="admonition danger"> <p class=admonition-title>Undefined behavior for pointers</p> <p>Writing data to the pointee (overload 3) of the result yields an undefined state.</p> </div> <div class="admonition danger"> <p class=admonition-title>Undefined behavior for numeric conversions</p> <p>Conversions between numeric types are performed by the corresponding <code>from_json()</code> implementation using the target C++ type. When converting between numeric types, the library does not check whether the source value is representable by the target type.</p> <p>If the source value is outside the range of the target type, the behavior is the same as the corresponding C++ conversion. In particular, converting a floating-point value to an integer type that cannot represent the value results in undefined behavior.</p> <p>See <a href=../../../features/types/number_handling/#number-conversion>Number conversion</a> for more information.</p> </div> <div class="admonition note"> <p class=admonition-title><code>std::optional</code> conversions</p> <p>Prior to version 3.13.0, <code class=highlight><span class=n>get</span><span class=o>&lt;</span><span class=n>std</span><span class=o>::</span><span class=n>optional</span><span class=o>&lt;</span><span class=n>T</span><span class=o>&gt;&gt;</span><span class=p>()</span></code> (and other conversions to <code>std::optional&lt;T&gt;</code>) failed to compile in every configuration, due to an internal implementation bug that made the <code>from_json</code> overload for <code>std::optional</code> unreachable regardless of the <a href=../../macros/json_use_implicit_conversions/ ><code>JSON_USE_IMPLICIT_CONVERSIONS</code></a> setting. This has been fixed.</p> </div> <h2 id=examples>Examples<a class=headerlink href=#examples title="Permanent link">&para;</a></h2> <details class=example> <summary>Example</summary> <p>The example below shows several conversions from <abbr title="JavaScript Object Notation">JSON</abbr> values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers, (2) A <abbr title="JavaScript Object Notation">JSON</abbr> array can be converted to a standard <code>std::vector&lt;short&gt;</code>, (3) A <abbr title="JavaScript Object Notation">JSON</abbr> object can be converted to C++ associative containers such as <code>std::unordered_map&lt;std::string, json&gt;</code>.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf>&lt;iostream&gt;</span>
<span class=cp>#include</span><span class=w> </span><span class=cpf>&lt;unordered_map&gt;</span>
<span class=cp>#include</span><span class=w> </span><span class=cpf>&lt;nlohmann/json.hpp&gt;</span>
@@ -103,4 +103,4 @@
<span class=p>}</span>
</code></pre></div> <p>Output:</p> <div class=highlight><pre><span></span><code><span class=mi>17</span><span class=w> </span><span class=mi>17</span><span class=w> </span><span class=mi>17</span><span class=w> </span><span class=mi>17</span>
<span class=kc>true</span>
</code></pre></div> </details> <h2 id=see-also>See also<a class=headerlink href=#see-also title="Permanent link">&para;</a></h2> <ul> <li><a href=../get_to/ >get_to</a> convert and write into a passed value</li> <li><a href=../get_ptr/ >get_ptr</a> get a pointer to the stored value</li> <li><a href=../get_ref/ >get_ref</a> get a reference to the stored value</li> <li><a href=../operator_ValueType/ >operator ValueType</a> get a value via implicit conversion</li> <li><a href=../../../features/conversions/ >Converting values</a> - the type conversions article</li> </ul> <h2 id=version-history>Version history<a class=headerlink href=#version-history title="Permanent link">&para;</a></h2> <ol> <li>Since version 2.1.0.</li> <li>Since version 2.1.0. Extended to work with other specializations of <code>basic_json</code> in version 3.2.0.</li> <li>Since version 1.0.0.</li> </ol> <!-- https://squidfunk.github.io/mkdocs-material/reference/tooltips/#adding-a-glossary --> <aside class=md-source-file> <span class=md-source-file__fact> <span class=md-icon title="Last update"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="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> <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date" title="July 9, 2026 15:15:57 UTC">July 9, 2026</span> </span> </aside> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> <div class=md-copyright__highlight> Copyright &copy; 2013-2026 Niels Lohmann </div> </div> <div class=md-social> <a href="https://github.com/nlohmann" target="_blank" rel="noopener" title="github.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 512 512"><!-- Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M173.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M252.8 8C114.1 8 8 113.3 8 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C436.2 457.8 504 362.9 504 252 504 113.3 391.5 8 252.8 8M105.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg> </a> <a href="https://www.linkedin.com/in/nielslohmann/" target="_blank" rel="noopener" title="www.linkedin.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3M135.4 416H69V202.2h66.5V416zM102.2 96a38.5 38.5 0 1 1 0 77 38.5 38.5 0 1 1 0-77m282.1 320h-66.4V312c0-24.8-.5-56.Line truncated
</code></pre></div> </details> <h2 id=see-also>See also<a class=headerlink href=#see-also title="Permanent link">&para;</a></h2> <ul> <li><a href=../get_to/ >get_to</a> convert and write into a passed value</li> <li><a href=../get_ptr/ >get_ptr</a> get a pointer to the stored value</li> <li><a href=../get_ref/ >get_ref</a> get a reference to the stored value</li> <li><a href=../operator_ValueType/ >operator ValueType</a> get a value via implicit conversion</li> <li><a href=../../../features/conversions/ >Converting values</a> - the type conversions article</li> </ul> <h2 id=version-history>Version history<a class=headerlink href=#version-history title="Permanent link">&para;</a></h2> <ol> <li>Since version 2.1.0.</li> <li>Since version 2.1.0. Extended to work with other specializations of <code>basic_json</code> in version 3.2.0.</li> <li>Since version 1.0.0.</li> </ol> <!-- https://squidfunk.github.io/mkdocs-material/reference/tooltips/#adding-a-glossary --> <aside class=md-source-file> <span class=md-source-file__fact> <span class=md-icon title="Last update"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="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> <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date" title="July 9, 2026 15:24:19 UTC">July 9, 2026</span> </span> </aside> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> <div class=md-copyright__highlight> Copyright &copy; 2013-2026 Niels Lohmann </div> </div> <div class=md-social> <a href="https://github.com/nlohmann" target="_blank" rel="noopener" title="github.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 512 512"><!-- Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M173.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M252.8 8C114.1 8 8 113.3 8 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C436.2 457.8 504 362.9 504 252 504 113.3 391.5 8 252.8 8M105.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg> </a> <a href="https://www.linkedin.com/in/nielslohmann/" target="_blank" rel="noopener" title="www.linkedin.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3M135.4 416H69V202.2h66.5V416zM102.2 96a38.5 38.5 0 1 1 0 77 38.5 38.5 0 1 1 0-77m282.1 320h-66.4V312c0-24.8-.5-56.Line truncated
+4
View File
@@ -94,6 +94,10 @@ If the source value is outside the range of the target type, the behavior is the
See [Number conversion](https://json.nlohmann.me/features/types/number_handling/#number-conversion) for more information.
`std::optional` conversions
Prior to version 3.13.0, `get<std::optional<T>>()` (and other conversions to `std::optional<T>`) failed to compile in every configuration, due to an internal implementation bug that made the `from_json` overload for `std::optional` unreachable regardless of the [`JSON_USE_IMPLICIT_CONVERSIONS`](https://json.nlohmann.me/api/macros/json_use_implicit_conversions/index.md) setting. This has been fixed.
## Examples
Example