mirror of
https://github.com/nlohmann/json.git
synced 2026-10-18 12:08:12 +00:00
deploy: 26cfec34be
This commit is contained in:
1 parent
4ce072a05e
commit
9cd1c63d00
330 files changed
+5398
-1012
No files matched your search
@@ -0,0 +1,55 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/architecture/" rel="canonical"><link href=../design_goals/ rel=prev><link href=../customers/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Architecture - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.61a430c9.css"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#architecture class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Architecture </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-seLine truncated
|
||||
<span class=n>value_t</span><span class=w> </span><span class=n>m_type</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=n>value_t</span><span class=o>::</span><span class=n>null</span><span class=p>;</span>
|
||||
|
||||
<span class=c1>/// the value of the current element</span>
|
||||
<span class=n>json_value</span><span class=w> </span><span class=n>m_value</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>{};</span>
|
||||
</code></pre></div> <p>with</p> <div class=highlight><pre><span></span><code><span class=k>enum</span><span class=w> </span><span class=k>class</span><span class=w> </span><span class=nc>value_t</span><span class=w> </span><span class=o>:</span><span class=w> </span><span class=n>std</span><span class=o>::</span><span class=kt>uint8_t</span>
|
||||
<span class=p>{</span>
|
||||
<span class=w> </span><span class=n>null</span><span class=p>,</span><span class=w> </span><span class=c1>///< null value</span>
|
||||
<span class=w> </span><span class=n>object</span><span class=p>,</span><span class=w> </span><span class=c1>///< object (unordered set of name/value pairs)</span>
|
||||
<span class=w> </span><span class=n>array</span><span class=p>,</span><span class=w> </span><span class=c1>///< array (ordered collection of values)</span>
|
||||
<span class=w> </span><span class=n>string</span><span class=p>,</span><span class=w> </span><span class=c1>///< string value</span>
|
||||
<span class=w> </span><span class=n>boolean</span><span class=p>,</span><span class=w> </span><span class=c1>///< boolean value</span>
|
||||
<span class=w> </span><span class=n>number_integer</span><span class=p>,</span><span class=w> </span><span class=c1>///< number value (signed integer)</span>
|
||||
<span class=w> </span><span class=n>number_unsigned</span><span class=p>,</span><span class=w> </span><span class=c1>///< number value (unsigned integer)</span>
|
||||
<span class=w> </span><span class=n>number_float</span><span class=p>,</span><span class=w> </span><span class=c1>///< number value (floating-point)</span>
|
||||
<span class=w> </span><span class=n>binary</span><span class=p>,</span><span class=w> </span><span class=c1>///< binary array (ordered collection of bytes)</span>
|
||||
<span class=w> </span><span class=n>discarded</span><span class=w> </span><span class=c1>///< discarded by the parser callback function</span>
|
||||
<span class=p>};</span>
|
||||
|
||||
<span class=k>union</span><span class=w> </span><span class=nc>json_value</span><span class=w> </span><span class=p>{</span>
|
||||
<span class=w> </span><span class=c1>/// object (stored with pointer to save storage)</span>
|
||||
<span class=w> </span><span class=n>object_t</span><span class=w> </span><span class=o>*</span><span class=n>object</span><span class=p>;</span>
|
||||
<span class=w> </span><span class=c1>/// array (stored with pointer to save storage)</span>
|
||||
<span class=w> </span><span class=n>array_t</span><span class=w> </span><span class=o>*</span><span class=n>array</span><span class=p>;</span>
|
||||
<span class=w> </span><span class=c1>/// string (stored with pointer to save storage)</span>
|
||||
<span class=w> </span><span class=n>string_t</span><span class=w> </span><span class=o>*</span><span class=n>string</span><span class=p>;</span>
|
||||
<span class=w> </span><span class=c1>/// binary (stored with pointer to save storage)</span>
|
||||
<span class=w> </span><span class=n>binary_t</span><span class=w> </span><span class=o>*</span><span class=n>binary</span><span class=p>;</span>
|
||||
<span class=w> </span><span class=c1>/// boolean</span>
|
||||
<span class=w> </span><span class=n>boolean_t</span><span class=w> </span><span class=n>boolean</span><span class=p>;</span>
|
||||
<span class=w> </span><span class=c1>/// number (integer)</span>
|
||||
<span class=w> </span><span class=n>number_integer_t</span><span class=w> </span><span class=n>number_integer</span><span class=p>;</span>
|
||||
<span class=w> </span><span class=c1>/// number (unsigned integer)</span>
|
||||
<span class=w> </span><span class=n>number_unsigned_t</span><span class=w> </span><span class=n>number_unsigned</span><span class=p>;</span>
|
||||
<span class=w> </span><span class=c1>/// number (floating-point)</span>
|
||||
<span class=w> </span><span class=n>number_float_t</span><span class=w> </span><span class=n>number_float</span><span class=p>;</span>
|
||||
<span class=p>};</span>
|
||||
</code></pre></div> <h2 id=parsing-inputs-deserialization>Parsing inputs (deserialization)<a class=headerlink href=#parsing-inputs-deserialization title="Permanent link">¶</a></h2> <p>Input is read via <strong>input adapters</strong> that abstract a source with a common interface:</p> <div class=highlight><pre><span></span><code><span class=c1>/// read a single character</span>
|
||||
<span class=n>std</span><span class=o>::</span><span class=n>char_traits</span><span class=o><</span><span class=kt>char</span><span class=o>>::</span><span class=n>int_type</span><span class=w> </span><span class=n>get_character</span><span class=p>()</span><span class=w> </span><span class=k>noexcept</span><span class=p>;</span>
|
||||
|
||||
<span class=c1>/// read multiple characters to a destination buffer and</span>
|
||||
<span class=c1>/// returns the number of characters successfully read</span>
|
||||
<span class=k>template</span><span class=o><</span><span class=k>class</span><span class=w> </span><span class=nc>T</span><span class=o>></span>
|
||||
<span class=n>std</span><span class=o>::</span><span class=kt>size_t</span><span class=w> </span><span class=n>get_elements</span><span class=p>(</span><span class=n>T</span><span class=o>*</span><span class=w> </span><span class=n>dest</span><span class=p>,</span><span class=w> </span><span class=n>std</span><span class=o>::</span><span class=kt>size_t</span><span class=w> </span><span class=n>count</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=mi>1</span><span class=p>);</span>
|
||||
</code></pre></div> <p>List examples of input adapters.</p> <h2 id=sax-interface><abbr title="Simple API for XML">SAX</abbr> Interface<a class=headerlink href=#sax-interface title="Permanent link">¶</a></h2> <p>TODO</p> <h2 id=writing-outputs-serialization>Writing outputs (serialization)<a class=headerlink href=#writing-outputs-serialization title="Permanent link">¶</a></h2> <p>Output is written via <strong>output adapters</strong>:</p> <div class=highlight><pre><span></span><code><span class=k>template</span><span class=o><</span><span class=k>typename</span><span class=w> </span><span class=nc>T</span><span class=o>></span>
|
||||
<span class=kt>void</span><span class=w> </span><span class=n>write_character</span><span class=p>(</span><span class=n>CharType</span><span class=w> </span><span class=n>c</span><span class=p>);</span>
|
||||
|
||||
<span class=k>template</span><span class=o><</span><span class=k>typename</span><span class=w> </span><span class=nc>CharType</span><span class=o>></span>
|
||||
<span class=kt>void</span><span class=w> </span><span class=n>write_characters</span><span class=p>(</span><span class=k>const</span><span class=w> </span><span class=n>CharType</span><span class=o>*</span><span class=w> </span><span class=n>s</span><span class=p>,</span><span class=w> </span><span class=n>std</span><span class=o>::</span><span class=kt>size_t</span><span class=w> </span><span class=n>length</span><span class=p>);</span>
|
||||
</code></pre></div> <p>List examples of output adapters.</p> <h2 id=value-conversion>Value conversion<a class=headerlink href=#value-conversion title="Permanent link">¶</a></h2> <div class=highlight><pre><span></span><code><span class=k>template</span><span class=o><</span><span class=k>class</span><span class=w> </span><span class=nc>T</span><span class=o>></span>
|
||||
<span class=kt>void</span><span class=w> </span><span class=n>to_json</span><span class=p>(</span><span class=n>basic_json</span><span class=o>&</span><span class=w> </span><span class=n>j</span><span class=p>,</span><span class=w> </span><span class=k>const</span><span class=w> </span><span class=n>T</span><span class=o>&</span><span class=w> </span><span class=n>t</span><span class=p>);</span>
|
||||
|
||||
<span class=k>template</span><span class=o><</span><span class=k>class</span><span class=w> </span><span class=nc>T</span><span class=o>></span>
|
||||
<span class=kt>void</span><span class=w> </span><span class=n>from_json</span><span class=p>(</span><span class=k>const</span><span class=w> </span><span class=n>basic_json</span><span class=o>&</span><span class=w> </span><span class=n>j</span><span class=p>,</span><span class=w> </span><span class=n>T</span><span class=o>&</span><span class=w> </span><span class=n>t</span><span class=p>);</span>
|
||||
</code></pre></div> <h2 id=additional-features>Additional features<a class=headerlink href=#additional-features title="Permanent link">¶</a></h2> <ul> <li><abbr title="JavaScript Object Notation">JSON</abbr> Pointers</li> <li>Binary formats</li> <li>Custom base class</li> <li>Conversion macros</li> </ul> <h2 id=details-namespace>Details namespace<a class=headerlink href=#details-namespace title="Permanent link">¶</a></h2> <ul> <li>C++ feature backports</li> </ul> <!-- 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">January 17, 2025</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 © 2013-2025 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 496 512"><!-- Font Awesome Free 6.7.1 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 2024 Fonticons, Inc.--><path d="M165.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.9M244.8 8C106.1 8 0 113.3 0 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.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.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 6.7.1 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 2024 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.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5m282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9z"/></svg> </a> <a href="https://www.xing.com/profile/Niels_Lohmann" target="_blank" rel="noopener" title="www.xing.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 384 512"><!-- Font Awesome Free 6.7.1 by @fontawesome - httLine truncated
|
||||
@@ -1 +1,14 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href=https://json.nlohmann.me/home/code_of_conduct/ rel=canonical><link href=../license/ rel=prev><link href=../faq/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Code of Conduct - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#contributor-covenant-code-of-conduct class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Code of Conduct </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 Line truncated
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Redirecting...</title>
|
||||
<link rel="canonical" href="../../community/code_of_conduct/">
|
||||
<script>var anchor=window.location.hash.substr(1);location.href="../../community/code_of_conduct/"+(anchor?"#"+anchor:"")</script>
|
||||
<meta http-equiv="refresh" content="0; url=../../community/code_of_conduct/">
|
||||
</head>
|
||||
<body>
|
||||
You're being redirected to a <a href="../../community/code_of_conduct/">new destination</a>.
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href=https://json.nlohmann.me/home/customers/ rel=canonical><link href=../design_goals/ rel=prev><link href=../sponsors/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Customers - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#customers class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Customers </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9Line truncated
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/customers/" rel="canonical"><link href=../architecture/ rel=prev><link href=../sponsors/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Customers - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.61a430c9.css"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#customers class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Customers </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-search data-md-Line truncated
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href=https://json.nlohmann.me/home/design_goals/ rel=canonical><link href=../releases/ rel=prev><link href=../customers/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Design goals - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#design-goals class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Design goals </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 Line truncated
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/design_goals/" rel="canonical"><link href=../releases/ rel=prev><link href=../architecture/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Design goals - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.61a430c9.css"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#design-goals class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Design goals </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-seaLine truncated
|
||||
+53
-54
@@ -1,4 +1,4 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href=https://json.nlohmann.me/home/exceptions/ rel=canonical><link href=../faq/ rel=prev><link href=../releases/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Exceptions - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#exceptions class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Exceptions </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.Line truncated
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/exceptions/" rel="canonical"><link href=../faq/ rel=prev><link href=../releases/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Exceptions - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.61a430c9.css"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#exceptions class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Exceptions </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-search data-md-compoLine truncated
|
||||
direction LR
|
||||
class `std::exception` {
|
||||
<<interface>>
|
||||
@@ -34,7 +34,7 @@
|
||||
<span class=cp> std::abort();}</span>
|
||||
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
</code></pre></div> </details> <p>Note the explanatory <a href=https://en.cppreference.com/w/cpp/error/exception/what><code>what()</code></a> string of exceptions is not available for MSVC if exceptions are disabled, see <a href=https://github.com/nlohmann/json/discussions/2824>#2824</a>.</p> <p>See <a href=../../api/macros/json_throw_user/ >documentation of <code>JSON_TRY_USER</code>, <code>JSON_CATCH_USER</code> and <code>JSON_THROW_USER</code></a> for more information.</p> <h3 id=extended-diagnostic-messages>Extended diagnostic messages<a class=headerlink href=#extended-diagnostic-messages title="Permanent link">¶</a></h3> <p>Exceptions in the library are thrown in the local context of the JSON value they are detected. This makes detailed diagnostics messages, and hence debugging, difficult.</p> <details class=example> <summary>Example</summary> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
</code></pre></div> </details> <p>Note the explanatory <a href="https://en.cppreference.com/w/cpp/error/exception/what"><code>what()</code></a> string of exceptions is not available for <abbr title="Microsoft Visual C++">MSVC</abbr> if exceptions are disabled, see <a href="https://github.com/nlohmann/json/discussions/2824">#2824</a>.</p> <p>See <a href=../../api/macros/json_throw_user/ >documentation of <code>JSON_TRY_USER</code>, <code>JSON_CATCH_USER</code> and <code>JSON_THROW_USER</code></a> for more information.</p> <h3 id=extended-diagnostic-messages>Extended diagnostic messages<a class=headerlink href=#extended-diagnostic-messages title="Permanent link">¶</a></h3> <p>Exceptions in the library are thrown in the local context of the <abbr title="JavaScript Object Notation">JSON</abbr> value they are detected. This makes detailed diagnostics messages, and hence debugging, difficult.</p> <details class=example> <summary>Example</summary> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
|
||||
<span class=k>using</span><span class=w> </span><span class=n>json</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=n>nlohmann</span><span class=o>::</span><span class=n>json</span><span class=p>;</span>
|
||||
@@ -55,7 +55,7 @@
|
||||
<span class=w> </span><span class=p>}</span>
|
||||
<span class=p>}</span>
|
||||
</code></pre></div> <p>Output:</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.302] type must be number, but is string
|
||||
</code></pre></div> <p>This exception can be hard to debug if storing the value <code class=highlight><span class=s>"12"</span></code> and accessing it is further apart.</p> </details> <p>To create better diagnostics messages, each JSON value needs a pointer to its parent value such that a global context (i.e., a path from the root value to the value that lead to the exception) can be created. That global context is provided as <a href=../../features/json_pointer/ >JSON Pointer</a>.</p> <p>As this global context comes at the price of storing one additional pointer per JSON value and runtime overhead to maintain the parent relation, extended diagnostics are disabled by default. They can, however, be enabled by defining the preprocessor symbol <a href=../../api/macros/json_diagnostics/ ><code>JSON_DIAGNOSTICS</code></a> to <code>1</code> before including <code>json.hpp</code>.</p> <details class=example> <summary>Example</summary> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
</code></pre></div> <p>This exception can be hard to debug if storing the value <code class=highlight><span class=s>"12"</span></code> and accessing it is further apart.</p> </details> <p>To create better diagnostics messages, each <abbr title="JavaScript Object Notation">JSON</abbr> value needs a pointer to its parent value such that a global context (i.e., a path from the root value to the value that lead to the exception) can be created. That global context is provided as <a href=../../features/json_pointer/ ><abbr title="JavaScript Object Notation">JSON</abbr> Pointer</a>.</p> <p>As this global context comes at the price of storing one additional pointer per <abbr title="JavaScript Object Notation">JSON</abbr> value and runtime overhead to maintain the parent relation, extended diagnostics are disabled by default. They can, however, be enabled by defining the preprocessor symbol <a href=../../api/macros/json_diagnostics/ ><code>JSON_DIAGNOSTICS</code></a> to <code>1</code> before including <code>json.hpp</code>.</p> <details class=example> <summary>Example</summary> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
|
||||
<span class=cp># define JSON_DIAGNOSTICS 1</span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
@@ -78,7 +78,7 @@
|
||||
<span class=w> </span><span class=p>}</span>
|
||||
<span class=p>}</span>
|
||||
</code></pre></div> <p>Output:</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.302] (/address/housenumber) type must be number, but is string
|
||||
</code></pre></div> <p>Now the exception message contains a JSON Pointer <code>/address/housenumber</code> that indicates which value has the wrong type.</p> </details> <p>See <a href=../../api/macros/json_diagnostics/ >documentation of <code>JSON_DIAGNOSTICS</code></a> for more information.</p> <h2 id=parse-errors>Parse errors<a class=headerlink href=#parse-errors title="Permanent link">¶</a></h2> <p>This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of JSON text, CBOR, MessagePack, as well as when using JSON Patch.</p> <p>Exceptions have ids 1xx.</p> <div class="admonition info"> <p class=admonition-title>Byte index</p> <p>Member <code>byte</code> holds the byte index of the last read character in the input file.</p> <p>For an input with n bytes, 1 is the index of the first character and n+1 is the index of the terminating null byte or the end of file. This also holds true when reading a byte vector (CBOR or MessagePack).</p> </div> <details class=example> <summary>Example</summary> <p>The following code shows how a <code>parse_error</code> exception can be caught.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
</code></pre></div> <p>Now the exception message contains a <abbr title="JavaScript Object Notation">JSON</abbr> Pointer <code>/address/housenumber</code> that indicates which value has the wrong type.</p> </details> <p>See <a href=../../api/macros/json_diagnostics/ >documentation of <code>JSON_DIAGNOSTICS</code></a> for more information.</p> <h2 id=parse-errors>Parse errors<a class=headerlink href=#parse-errors title="Permanent link">¶</a></h2> <p>This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of <abbr title="JavaScript Object Notation">JSON</abbr> text, <abbr title="Concise Binary Object Representation">CBOR</abbr>, MessagePack, as well as when using <abbr title="JavaScript Object Notation">JSON</abbr> Patch.</p> <p>Exceptions have ids 1xx.</p> <div class="admonition info"> <p class=admonition-title>Byte index</p> <p>Member <code>byte</code> holds the byte index of the last read character in the input file.</p> <p>For an input with n bytes, 1 is the index of the first character and n+1 is the index of the terminating null byte or the end of file. This also holds true when reading a byte vector (<abbr title="Concise Binary Object Representation">CBOR</abbr> or MessagePack).</p> </div> <details class=example> <summary>Example</summary> <p>The following code shows how a <code>parse_error</code> exception can be caught.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
|
||||
<span class=k>using</span><span class=w> </span><span class=n>json</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=n>nlohmann</span><span class=o>::</span><span class=n>json</span><span class=p>;</span>
|
||||
@@ -101,28 +101,28 @@
|
||||
</code></pre></div> <p>Output:</p> <div class=highlight><pre><span></span><code>message: [json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal
|
||||
exception id: 101
|
||||
byte position of error: 8
|
||||
</code></pre></div> </details> <h3 id=jsonexceptionparse_error101>json.exception.parse_error.101<a class=headerlink href=#jsonexceptionparse_error101 title="Permanent link">¶</a></h3> <p>This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member <code>byte</code> indicates the error position.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Input ended prematurely:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at 2: unexpected end of input; expected string literal
|
||||
</code></pre></div> </details> <h3 id=jsonexceptionparse_error101>json.exception.parse_error.101<a class=headerlink href=#jsonexceptionparse_error101 title="Permanent link">¶</a></h3> <p>This error indicates a syntax error while deserializing a <abbr title="JavaScript Object Notation">JSON</abbr> text. The error message describes that an unexpected token (character) was encountered, and the member <code>byte</code> indicates the error position.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Input ended prematurely:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at 2: unexpected end of input; expected string literal
|
||||
</code></pre></div> <p>No input:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON
|
||||
</code></pre></div> <p>Control character was not escaped:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0009 (HT) must be escaped to \u0009 or \\; last read: '"<U+0009>'"
|
||||
</code></pre></div> <p>String was not closed:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: missing closing quote; last read: '"'
|
||||
</code></pre></div> <p>Invalid number format:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E'
|
||||
</code></pre></div> <p><code>\u</code> was not be followed by four hex digits:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\u' must be followed by 4 hex digits; last read: '"\u01"'
|
||||
</code></pre></div> <p>Invalid UTF-8 surrogate pair:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '"\uD7FF\uDC00'"
|
||||
</code></pre></div> <p>Invalid UTF-8 byte:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 3, column 24: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"vous \352t'
|
||||
</code></pre></div> </div> <div class="admonition tip"> <p class=admonition-title>Tip</p> <ul> <li>Make sure the input is correctly read. Try to write the input to standard output to check if, for instance, the input file was successfully opened.</li> <li>Paste the input to a JSON validator like <a href=http://jsonlint.com>http://jsonlint.com</a> or a tool like <a href=https://stedolan.github.io/jq/ >jq</a>.</li> </ul> </div> <h3 id=jsonexceptionparse_error102>json.exception.parse_error.102<a class=headerlink href=#jsonexceptionparse_error102 title="Permanent link">¶</a></h3> <p>JSON uses the <code>\uxxxx</code> format to describe Unicode characters. Code points above 0xFFFF are split into two <code>\uxxxx</code> entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>parse error at 14: missing or wrong low surrogate
|
||||
</code></pre></div> <p>Invalid <abbr title="Unicode Transformation Format">UTF</abbr>-8 surrogate pair:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '"\uD7FF\uDC00'"
|
||||
</code></pre></div> <p>Invalid <abbr title="Unicode Transformation Format">UTF</abbr>-8 byte:</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.101] parse error at line 3, column 24: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"vous \352t'
|
||||
</code></pre></div> </div> <div class="admonition tip"> <p class=admonition-title>Tip</p> <ul> <li>Make sure the input is correctly read. Try to write the input to standard output to check if, for instance, the input file was successfully opened.</li> <li>Paste the input to a <abbr title="JavaScript Object Notation">JSON</abbr> validator like <a href="http://jsonlint.com">http://jsonlint.com</a> or a tool like <a href="https://stedolan.github.io/jq/">jq</a>.</li> </ul> </div> <h3 id=jsonexceptionparse_error102>json.exception.parse_error.102<a class=headerlink href=#jsonexceptionparse_error102 title="Permanent link">¶</a></h3> <p><abbr title="JavaScript Object Notation">JSON</abbr> uses the <code>\uxxxx</code> format to describe Unicode characters. Code points above 0xFFFF are split into two <code>\uxxxx</code> entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>parse error at 14: missing or wrong low surrogate
|
||||
</code></pre></div> </div> <div class="admonition note"> <p class=admonition-title>Note</p> <p>This exception is not used any more. Instead <a href=#jsonexceptionparse_error101>json.exception.parse_error.101</a> with a more detailed description is used.</p> </div> <h3 id=jsonexceptionparse_error103>json.exception.parse_error.103<a class=headerlink href=#jsonexceptionparse_error103 title="Permanent link">¶</a></h3> <p>Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>parse error: code points above 0x10FFFF are invalid
|
||||
</code></pre></div> </div> <div class="admonition note"> <p class=admonition-title>Note</p> <p>This exception is not used any more. Instead <a href=#jsonexceptionparse_error101>json.exception.parse_error.101</a> with a more detailed description is used.</p> </div> <h3 id=jsonexceptionparse_error104>json.exception.parse_error.104<a class=headerlink href=#jsonexceptionparse_error104 title="Permanent link">¶</a></h3> <p><a href=https://tools.ietf.org/html/rfc6902>RFC 6902</a> requires a JSON Patch document to be a JSON document that represents an array of objects.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.104] parse error: JSON patch must be an array of objects
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error105>json.exception.parse_error.105<a class=headerlink href=#jsonexceptionparse_error105 title="Permanent link">¶</a></h3> <p>An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'
|
||||
</code></pre></div> </div> <div class="admonition note"> <p class=admonition-title>Note</p> <p>This exception is not used any more. Instead <a href=#jsonexceptionparse_error101>json.exception.parse_error.101</a> with a more detailed description is used.</p> </div> <h3 id=jsonexceptionparse_error104>json.exception.parse_error.104<a class=headerlink href=#jsonexceptionparse_error104 title="Permanent link">¶</a></h3> <p><a href="https://tools.ietf.org/html/rfc6902"><abbr title="Request for Comments">RFC</abbr> 6902</a> requires a <abbr title="JavaScript Object Notation">JSON</abbr> Patch document to be a <abbr title="JavaScript Object Notation">JSON</abbr> document that represents an array of objects.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.104] parse error: JSON patch must be an array of objects
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error105>json.exception.parse_error.105<a class=headerlink href=#jsonexceptionparse_error105 title="Permanent link">¶</a></h3> <p>An operation of a <abbr title="JavaScript Object Notation">JSON</abbr> Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from'
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.105] parse error: operation value 'foo' is invalid
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error106>json.exception.parse_error.106<a class=headerlink href=#jsonexceptionparse_error106 title="Permanent link">¶</a></h3> <p>An array index in a JSON Pointer (<a href=https://tools.ietf.org/html/rfc6901>RFC 6901</a>) may be <code>0</code> or any number without a leading <code>0</code>.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error107>json.exception.parse_error.107<a class=headerlink href=#jsonexceptionparse_error107 title="Permanent link">¶</a></h3> <p>A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a <code>/</code> character.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'foo'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error108>json.exception.parse_error.108<a class=headerlink href=#jsonexceptionparse_error108 title="Permanent link">¶</a></h3> <p>In a JSON Pointer, only <code>~0</code> and <code>~1</code> are valid escape sequences.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error109>json.exception.parse_error.109<a class=headerlink href=#jsonexceptionparse_error109 title="Permanent link">¶</a></h3> <p>A JSON Pointer array index must be a number.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.109] parse error: array index 'one' is not a number
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error106>json.exception.parse_error.106<a class=headerlink href=#jsonexceptionparse_error106 title="Permanent link">¶</a></h3> <p>An array index in a <abbr title="JavaScript Object Notation">JSON</abbr> Pointer (<a href="https://tools.ietf.org/html/rfc6901"><abbr title="Request for Comments">RFC</abbr> 6901</a>) may be <code>0</code> or any number without a leading <code>0</code>.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error107>json.exception.parse_error.107<a class=headerlink href=#jsonexceptionparse_error107 title="Permanent link">¶</a></h3> <p>A <abbr title="JavaScript Object Notation">JSON</abbr> Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a <code>/</code> character.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'foo'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error108>json.exception.parse_error.108<a class=headerlink href=#jsonexceptionparse_error108 title="Permanent link">¶</a></h3> <p>In a <abbr title="JavaScript Object Notation">JSON</abbr> Pointer, only <code>~0</code> and <code>~1</code> are valid escape sequences.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error109>json.exception.parse_error.109<a class=headerlink href=#jsonexceptionparse_error109 title="Permanent link">¶</a></h3> <p>A <abbr title="JavaScript Object Notation">JSON</abbr> Pointer array index must be a number.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.109] parse error: array index 'one' is not a number
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.109] parse error: array index '+1' is not a number
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error110>json.exception.parse_error.110<a class=headerlink href=#jsonexceptionparse_error110 title="Permanent link">¶</a></h3> <p>When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error110>json.exception.parse_error.110<a class=headerlink href=#jsonexceptionparse_error110 title="Permanent link">¶</a></h3> <p>When parsing <abbr title="Concise Binary Object Representation">CBOR</abbr> or MessagePack, the byte vector ends before the complete value has been read.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: expected end of input; last byte: 0x5A
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error112>json.exception.parse_error.112<a class=headerlink href=#jsonexceptionparse_error112 title="Permanent link">¶</a></h3> <p>An unexpected byte was read in a <a href=../../features/binary_formats/ >binary format</a> or length information is invalid (<a href=../../features/binary_formats/bson/ >BSON</a>).</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0x1C
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error112>json.exception.parse_error.112<a class=headerlink href=#jsonexceptionparse_error112 title="Permanent link">¶</a></h3> <p>An unexpected byte was read in a <a href=../../features/binary_formats/ >binary format</a> or length information is invalid (<a href=../../features/binary_formats/bson/ ><abbr title="Binary JSON">BSON</abbr></a>).</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0x1C
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC1
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing BJData size: expected '#' after type information; last byte: 0x02
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x02
|
||||
@@ -131,8 +131,8 @@ byte position of error: 8
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error113>json.exception.parse_error.113<a class=headerlink href=#jsonexceptionparse_error113 title="Permanent link">¶</a></h3> <p>While parsing a map key, a value that is not a string has been read.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xFF
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing MessagePack string: expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0xFF
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON char: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error114>json.exception.parse_error.114<a class=headerlink href=#jsonexceptionparse_error114 title="Permanent link">¶</a></h3> <p>The parsing of the corresponding BSON record type is not implemented (yet).</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.114] parse error at byte 5: Unsupported BSON record type 0xFF
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error115>json.exception.parse_error.115<a class=headerlink href=#jsonexceptionparse_error115 title="Permanent link">¶</a></h3> <p>A UBJSON high-precision number could not be parsed.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptionparse_error114>json.exception.parse_error.114<a class=headerlink href=#jsonexceptionparse_error114 title="Permanent link">¶</a></h3> <p>The parsing of the corresponding <abbr title="Binary JSON">BSON</abbr> record type is not implemented (yet).</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.114] parse error at byte 5: Unsupported BSON record type 0xFF
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionparse_error115>json.exception.parse_error.115<a class=headerlink href=#jsonexceptionparse_error115 title="Permanent link">¶</a></h3> <p>A <abbr title="Universal Binary JSON">UBJSON</abbr> high-precision number could not be parsed.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A
|
||||
</code></pre></div> </div> <h2 id=iterator-errors>Iterator errors<a class=headerlink href=#iterator-errors title="Permanent link">¶</a></h2> <p>This exception is thrown if iterators passed to a library function do not match the expected semantics.</p> <p>Exceptions have ids 2xx.</p> <details class=example> <summary>Example</summary> <p>The following code shows how an <code>invalid_iterator</code> exception can be caught.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
|
||||
@@ -157,21 +157,21 @@ byte position of error: 8
|
||||
</code></pre></div> <p>Output:</p> <div class=highlight><pre><span></span><code>message: [json.exception.invalid_iterator.207] cannot use key() for non-object iterators
|
||||
exception id: 207
|
||||
</code></pre></div> </details> <h3 id=jsonexceptioninvalid_iterator201>json.exception.invalid_iterator.201<a class=headerlink href=#jsonexceptioninvalid_iterator201 title="Permanent link">¶</a></h3> <p>The iterators passed to constructor <code>basic_json(InputIT first, InputIT last)</code> are not compatible, meaning they do not belong to the same container. Therefore, the range (<code>first</code>, <code>last</code>) is invalid.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.201] iterators are not compatible
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator202>json.exception.invalid_iterator.202<a class=headerlink href=#jsonexceptioninvalid_iterator202 title="Permanent link">¶</a></h3> <p>In the <a href=../../api/basic_json/erase/ >erase</a> or insert function, the passed iterator <code>pos</code> does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.202] iterator does not fit current value
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator202>json.exception.invalid_iterator.202<a class=headerlink href=#jsonexceptioninvalid_iterator202 title="Permanent link">¶</a></h3> <p>In the <a href=../../api/basic_json/erase/ >erase</a> or insert function, the passed iterator <code>pos</code> does not belong to the <abbr title="JavaScript Object Notation">JSON</abbr> value for which the function was called. It hence does not define a valid position for the deletion/insertion.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.202] iterator does not fit current value
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.202] iterators first and last must point to objects
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptioninvalid_iterator203>json.exception.invalid_iterator.203<a class=headerlink href=#jsonexceptioninvalid_iterator203 title="Permanent link">¶</a></h3> <p>Either iterator passed to function <a href=../../api/basic_json/erase/ ><code>erase(IteratorType first, IteratorType last</code>)</a> does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.203] iterators do not fit current value
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptioninvalid_iterator203>json.exception.invalid_iterator.203<a class=headerlink href=#jsonexceptioninvalid_iterator203 title="Permanent link">¶</a></h3> <p>Either iterator passed to function <a href=../../api/basic_json/erase/ ><code>erase(IteratorType first, IteratorType last</code>)</a> does not belong to the <abbr title="JavaScript Object Notation">JSON</abbr> value from which values shall be erased. It hence does not define a valid range to delete values from.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.203] iterators do not fit current value
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator204>json.exception.invalid_iterator.204<a class=headerlink href=#jsonexceptioninvalid_iterator204 title="Permanent link">¶</a></h3> <p>When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an <a href=../../api/basic_json/erase/ >erase</a> function, this range has to be exactly (<code>begin(),</code> <code>end()),</code> because this is the only way the single stored value is expressed. All other ranges are invalid.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.204] iterators out of range
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator205>json.exception.invalid_iterator.205<a class=headerlink href=#jsonexceptioninvalid_iterator205 title="Permanent link">¶</a></h3> <p>When an iterator for a primitive type (number, boolean, or string) is passed to an <a href=../../api/basic_json/erase/ >erase</a> function, the iterator has to be the <code>begin()</code> iterator, because it is the only way to address the stored value. All other iterators are invalid.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.205] iterator out of range
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator206>json.exception.invalid_iterator.206<a class=headerlink href=#jsonexceptioninvalid_iterator206 title="Permanent link">¶</a></h3> <p>The iterators passed to constructor <code>basic_json(InputIT first, InputIT last)</code> belong to a JSON null value and hence to not define a valid range.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.206] cannot construct with iterators from null
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator207>json.exception.invalid_iterator.207<a class=headerlink href=#jsonexceptioninvalid_iterator207 title="Permanent link">¶</a></h3> <p>The <code>key()</code> member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.207] cannot use key() for non-object iterators
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator208>json.exception.invalid_iterator.208<a class=headerlink href=#jsonexceptioninvalid_iterator208 title="Permanent link">¶</a></h3> <p>The <code>operator[]</code> to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.208] cannot use operator[] for object iterators
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator209>json.exception.invalid_iterator.209<a class=headerlink href=#jsonexceptioninvalid_iterator209 title="Permanent link">¶</a></h3> <p>The offset operators (<code>+</code>, <code>-</code>, <code>+=</code>, <code>-=</code>) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.209] cannot use offsets with object iterators
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator206>json.exception.invalid_iterator.206<a class=headerlink href=#jsonexceptioninvalid_iterator206 title="Permanent link">¶</a></h3> <p>The iterators passed to constructor <code>basic_json(InputIT first, InputIT last)</code> belong to a <abbr title="JavaScript Object Notation">JSON</abbr> null value and hence to not define a valid range.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.206] cannot construct with iterators from null
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator207>json.exception.invalid_iterator.207<a class=headerlink href=#jsonexceptioninvalid_iterator207 title="Permanent link">¶</a></h3> <p>The <code>key()</code> member function can only be used on iterators belonging to a <abbr title="JavaScript Object Notation">JSON</abbr> object, because other types do not have a concept of a key.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.207] cannot use key() for non-object iterators
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator208>json.exception.invalid_iterator.208<a class=headerlink href=#jsonexceptioninvalid_iterator208 title="Permanent link">¶</a></h3> <p>The <code>operator[]</code> to specify a concrete offset cannot be used on iterators belonging to a <abbr title="JavaScript Object Notation">JSON</abbr> object, because <abbr title="JavaScript Object Notation">JSON</abbr> objects are unordered.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.208] cannot use operator[] for object iterators
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator209>json.exception.invalid_iterator.209<a class=headerlink href=#jsonexceptioninvalid_iterator209 title="Permanent link">¶</a></h3> <p>The offset operators (<code>+</code>, <code>-</code>, <code>+=</code>, <code>-=</code>) cannot be used on iterators belonging to a <abbr title="JavaScript Object Notation">JSON</abbr> object, because <abbr title="JavaScript Object Notation">JSON</abbr> objects are unordered.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.209] cannot use offsets with object iterators
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator210>json.exception.invalid_iterator.210<a class=headerlink href=#jsonexceptioninvalid_iterator210 title="Permanent link">¶</a></h3> <p>The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (<code>first</code>, <code>last</code>) is invalid.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.210] iterators do not fit
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator211>json.exception.invalid_iterator.211<a class=headerlink href=#jsonexceptioninvalid_iterator211 title="Permanent link">¶</a></h3> <p>The iterator range passed to the insert function must not be a subrange of the container to insert to.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.211] passed iterators may not belong to container
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator212>json.exception.invalid_iterator.212<a class=headerlink href=#jsonexceptioninvalid_iterator212 title="Permanent link">¶</a></h3> <p>When two iterators are compared, they must belong to the same container.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.212] cannot compare iterators of different containers
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator213>json.exception.invalid_iterator.213<a class=headerlink href=#jsonexceptioninvalid_iterator213 title="Permanent link">¶</a></h3> <p>The order of object iterators cannot be compared, because JSON objects are unordered.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.213] cannot compare order of object iterators
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator213>json.exception.invalid_iterator.213<a class=headerlink href=#jsonexceptioninvalid_iterator213 title="Permanent link">¶</a></h3> <p>The order of object iterators cannot be compared, because <abbr title="JavaScript Object Notation">JSON</abbr> objects are unordered.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.213] cannot compare order of object iterators
|
||||
</code></pre></div> </div> <h3 id=jsonexceptioninvalid_iterator214>json.exception.invalid_iterator.214<a class=headerlink href=#jsonexceptioninvalid_iterator214 title="Permanent link">¶</a></h3> <p>Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to <code>begin()</code>.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.invalid_iterator.214] cannot get value
|
||||
</code></pre></div> </div> <h2 id=type-errors>Type errors<a class=headerlink href=#type-errors title="Permanent link">¶</a></h2> <p>This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type does not match the expected semantics.</p> <p>Exceptions have ids 3xx.</p> <details class=example> <summary>Example</summary> <p>The following code shows how a <code>type_error</code> exception can be caught.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
</code></pre></div> </div> <h2 id=type-errors>Type errors<a class=headerlink href=#type-errors title="Permanent link">¶</a></h2> <p>This exception is thrown in case of a type error; that is, a library function is executed on a <abbr title="JavaScript Object Notation">JSON</abbr> value whose type does not match the expected semantics.</p> <p>Exceptions have ids 3xx.</p> <details class=example> <summary>Example</summary> <p>The following code shows how a <code>type_error</code> exception can be caught.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
|
||||
<span class=k>using</span><span class=w> </span><span class=n>json</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=n>nlohmann</span><span class=o>::</span><span class=n>json</span><span class=p>;</span>
|
||||
@@ -194,30 +194,30 @@ exception id: 207
|
||||
</code></pre></div> <p>Output:</p> <div class=highlight><pre><span></span><code>message: [json.exception.type_error.308] cannot use push_back() with string
|
||||
exception id: 308
|
||||
</code></pre></div> </details> <h3 id=jsonexceptiontype_error301>json.exception.type_error.301<a class=headerlink href=#jsonexceptiontype_error301 title="Permanent link">¶</a></h3> <p>To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.301] cannot create object from initializer list
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error302>json.exception.type_error.302<a class=headerlink href=#jsonexceptiontype_error302 title="Permanent link">¶</a></h3> <p>During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.302] type must be object, but is null
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error302>json.exception.type_error.302<a class=headerlink href=#jsonexceptiontype_error302 title="Permanent link">¶</a></h3> <p>During implicit or explicit value conversion, the <abbr title="JavaScript Object Notation">JSON</abbr> type must be compatible to the target type. For instance, a <abbr title="JavaScript Object Notation">JSON</abbr> string can only be converted into string types, but not into numbers or boolean types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.302] type must be object, but is null
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.type_error.302] type must be string, but is object
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error303>json.exception.type_error.303<a class=headerlink href=#jsonexceptiontype_error303 title="Permanent link">¶</a></h3> <p>To retrieve a reference to a value stored in a <code>basic_json</code> object with <code>get_ref</code>, the type of the reference must match the value type. For instance, for a JSON array, the <code>ReferenceType</code> must be <code>array_t &</code>.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error303>json.exception.type_error.303<a class=headerlink href=#jsonexceptiontype_error303 title="Permanent link">¶</a></h3> <p>To retrieve a reference to a value stored in a <code>basic_json</code> object with <code>get_ref</code>, the type of the reference must match the value type. For instance, for a <abbr title="JavaScript Object Notation">JSON</abbr> array, the <code>ReferenceType</code> must be <code>array_t &</code>.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number"
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error304>json.exception.type_error.304<a class=headerlink href=#jsonexceptiontype_error304 title="Permanent link">¶</a></h3> <p>The <code>at()</code> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.304] cannot use at() with string
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error304>json.exception.type_error.304<a class=headerlink href=#jsonexceptiontype_error304 title="Permanent link">¶</a></h3> <p>The <code>at()</code> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.304] cannot use at() with string
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.type_error.304] cannot use at() with number
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error305>json.exception.type_error.305<a class=headerlink href=#jsonexceptiontype_error305 title="Permanent link">¶</a></h3> <p>The <code>operator[]</code> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.305] cannot use operator[] with a string argument with array
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error305>json.exception.type_error.305<a class=headerlink href=#jsonexceptiontype_error305 title="Permanent link">¶</a></h3> <p>The <code>operator[]</code> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.305] cannot use operator[] with a string argument with array
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.type_error.305] cannot use operator[] with a numeric argument with object
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error306>json.exception.type_error.306<a class=headerlink href=#jsonexceptiontype_error306 title="Permanent link">¶</a></h3> <p>The <code>value()</code> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.306] cannot use value() with number
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error307>json.exception.type_error.307<a class=headerlink href=#jsonexceptiontype_error307 title="Permanent link">¶</a></h3> <p>The <a href=../../api/basic_json/erase/ ><code>erase()</code></a> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.307] cannot use erase() with string
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error308>json.exception.type_error.308<a class=headerlink href=#jsonexceptiontype_error308 title="Permanent link">¶</a></h3> <p>The <code>push_back()</code> and <code>operator+=</code> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.308] cannot use push_back() with string
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error309>json.exception.type_error.309<a class=headerlink href=#jsonexceptiontype_error309 title="Permanent link">¶</a></h3> <p>The <code>insert()</code> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.309] cannot use insert() with array
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error306>json.exception.type_error.306<a class=headerlink href=#jsonexceptiontype_error306 title="Permanent link">¶</a></h3> <p>The <code>value()</code> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.306] cannot use value() with number
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error307>json.exception.type_error.307<a class=headerlink href=#jsonexceptiontype_error307 title="Permanent link">¶</a></h3> <p>The <a href=../../api/basic_json/erase/ ><code>erase()</code></a> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.307] cannot use erase() with string
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error308>json.exception.type_error.308<a class=headerlink href=#jsonexceptiontype_error308 title="Permanent link">¶</a></h3> <p>The <code>push_back()</code> and <code>operator+=</code> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.308] cannot use push_back() with string
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error309>json.exception.type_error.309<a class=headerlink href=#jsonexceptiontype_error309 title="Permanent link">¶</a></h3> <p>The <code>insert()</code> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.309] cannot use insert() with array
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.type_error.309] cannot use insert() with number
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error310>json.exception.type_error.310<a class=headerlink href=#jsonexceptiontype_error310 title="Permanent link">¶</a></h3> <p>The <code>swap()</code> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.310] cannot use swap() with number
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error311>json.exception.type_error.311<a class=headerlink href=#jsonexceptiontype_error311 title="Permanent link">¶</a></h3> <p>The <code>emplace()</code> and <code>emplace_back()</code> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.311] cannot use emplace() with number
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error310>json.exception.type_error.310<a class=headerlink href=#jsonexceptiontype_error310 title="Permanent link">¶</a></h3> <p>The <code>swap()</code> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.310] cannot use swap() with number
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error311>json.exception.type_error.311<a class=headerlink href=#jsonexceptiontype_error311 title="Permanent link">¶</a></h3> <p>The <code>emplace()</code> and <code>emplace_back()</code> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p><div class=highlight><pre><span></span><code>[json.exception.type_error.311] cannot use emplace() with number
|
||||
</code></pre></div> <div class=highlight><pre><span></span><code>[json.exception.type_error.311] cannot use emplace_back() with number
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error312>json.exception.type_error.312<a class=headerlink href=#jsonexceptiontype_error312 title="Permanent link">¶</a></h3> <p>The <code>update()</code> member functions can only be executed for certain JSON types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.312] cannot use update() with array
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error313>json.exception.type_error.313<a class=headerlink href=#jsonexceptiontype_error313 title="Permanent link">¶</a></h3> <p>The <code>unflatten</code> function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well-defined.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.313] invalid value to unflatten
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error314>json.exception.type_error.314<a class=headerlink href=#jsonexceptiontype_error314 title="Permanent link">¶</a></h3> <p>The <code>unflatten</code> function only works for an object whose keys are JSON Pointers.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Calling <code>unflatten()</code> on an array <code class=highlight><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=mi>2</span><span class=p>,</span><span class=mi>3</span><span class=p>]</span></code>:</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.314] only objects can be unflattened
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error315>json.exception.type_error.315<a class=headerlink href=#jsonexceptiontype_error315 title="Permanent link">¶</a></h3> <p>The <code>unflatten()</code> function only works for an object whose keys are JSON Pointers and whose values are primitive.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Calling <code>unflatten()</code> on an object <code class=highlight><span class=p>{</span><span class=s2>"/1"</span><span class=p>,</span><span class=w> </span><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=mi>2</span><span class=p>,</span><span class=mi>3</span><span class=p>]}</span></code>:</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.315] values in object must be primitive
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error316>json.exception.type_error.316<a class=headerlink href=#jsonexceptiontype_error316 title="Permanent link">¶</a></h3> <p>The <code>dump()</code> function only works with UTF-8 encoded strings; that is, if you assign a <code>std::string</code> to a JSON value, make sure it is UTF-8 encoded.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Calling <code>dump()</code> on a JSON value containing an ISO 8859-1 encoded string: <div class=highlight><pre><span></span><code>[json.exception.type_error.316] invalid UTF-8 byte at index 15: 0x6F
|
||||
</code></pre></div></p> </div> <div class="admonition tip"> <p class=admonition-title>Tip</p> <ul> <li>Store the source file with UTF-8 encoding.</li> <li>Pass an error handler as last parameter to the <code>dump()</code> function to avoid this exception:<ul> <li><code>json::error_handler_t::replace</code> will replace invalid bytes sequences with <code>U+FFFD</code> </li> <li><code>json::error_handler_t::ignore</code> will silently ignore invalid byte sequences</li> </ul> </li> </ul> </div> <h3 id=jsonexceptiontype_error317>json.exception.type_error.317<a class=headerlink href=#jsonexceptiontype_error317 title="Permanent link">¶</a></h3> <p>The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw <code>true</code> or <code>null</code> JSON object cannot be serialized to BSON)</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p>Serializing <code class=highlight><span class=kc>null</span></code> to BSON: <div class=highlight><pre><span></span><code>[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is null
|
||||
</code></pre></div> Serializing <code class=highlight><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=mi>2</span><span class=p>,</span><span class=mi>3</span><span class=p>]</span></code> to BSON: <div class=highlight><pre><span></span><code>[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is array
|
||||
</code></pre></div></p> </div> <div class="admonition tip"> <p class=admonition-title>Tip</p> <p>Encapsulate the JSON value in an object. That is, instead of serializing <code class=highlight><span class=kc>true</span></code>, serialize <code class=highlight><span class=p>{</span><span class=nt>"value"</span><span class=p>:</span><span class=w> </span><span class=kc>true</span><span class=p>}</span></code></p> </div> <h2 id=out-of-range>Out of range<a class=headerlink href=#out-of-range title="Permanent link">¶</a></h2> <p>This exception is thrown in case a library function is called on an input parameter that exceeds the expected range, for instance in case of array indices or nonexisting object keys.</p> <p>Exceptions have ids 4xx.</p> <details class=example> <summary>Example</summary> <p>The following code shows how an <code>out_of_range</code> exception can be caught.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
</code></pre></div></p> </div> <h3 id=jsonexceptiontype_error312>json.exception.type_error.312<a class=headerlink href=#jsonexceptiontype_error312 title="Permanent link">¶</a></h3> <p>The <code>update()</code> member functions can only be executed for certain <abbr title="JavaScript Object Notation">JSON</abbr> types.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.312] cannot use update() with array
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error313>json.exception.type_error.313<a class=headerlink href=#jsonexceptiontype_error313 title="Permanent link">¶</a></h3> <p>The <code>unflatten</code> function converts an object whose keys are <abbr title="JavaScript Object Notation">JSON</abbr> Pointers back into an arbitrary nested <abbr title="JavaScript Object Notation">JSON</abbr> value. The <abbr title="JavaScript Object Notation">JSON</abbr> Pointers must not overlap, because then the resulting value would not be well-defined.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.313] invalid value to unflatten
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error314>json.exception.type_error.314<a class=headerlink href=#jsonexceptiontype_error314 title="Permanent link">¶</a></h3> <p>The <code>unflatten</code> function only works for an object whose keys are <abbr title="JavaScript Object Notation">JSON</abbr> Pointers.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Calling <code>unflatten()</code> on an array <code class=highlight><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=mi>2</span><span class=p>,</span><span class=mi>3</span><span class=p>]</span></code>:</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.314] only objects can be unflattened
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error315>json.exception.type_error.315<a class=headerlink href=#jsonexceptiontype_error315 title="Permanent link">¶</a></h3> <p>The <code>unflatten()</code> function only works for an object whose keys are <abbr title="JavaScript Object Notation">JSON</abbr> Pointers and whose values are primitive.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Calling <code>unflatten()</code> on an object <code class=highlight><span class=p>{</span><span class=s2>"/1"</span><span class=p>,</span><span class=w> </span><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=mi>2</span><span class=p>,</span><span class=mi>3</span><span class=p>]}</span></code>:</p> <div class=highlight><pre><span></span><code>[json.exception.type_error.315] values in object must be primitive
|
||||
</code></pre></div> </div> <h3 id=jsonexceptiontype_error316>json.exception.type_error.316<a class=headerlink href=#jsonexceptiontype_error316 title="Permanent link">¶</a></h3> <p>The <code>dump()</code> function only works with <abbr title="Unicode Transformation Format">UTF</abbr>-8 encoded strings; that is, if you assign a <code>std::string</code> to a <abbr title="JavaScript Object Notation">JSON</abbr> value, make sure it is <abbr title="Unicode Transformation Format">UTF</abbr>-8 encoded.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Calling <code>dump()</code> on a <abbr title="JavaScript Object Notation">JSON</abbr> value containing an <abbr title="International Organization for Standardization">ISO</abbr> 8859-1 encoded string: <div class=highlight><pre><span></span><code>[json.exception.type_error.316] invalid UTF-8 byte at index 15: 0x6F
|
||||
</code></pre></div></p> </div> <div class="admonition tip"> <p class=admonition-title>Tip</p> <ul> <li>Store the source file with <abbr title="Unicode Transformation Format">UTF</abbr>-8 encoding.</li> <li>Pass an error handler as last parameter to the <code>dump()</code> function to avoid this exception:<ul> <li><code>json::error_handler_t::replace</code> will replace invalid bytes sequences with <code>U+FFFD</code> </li> <li><code>json::error_handler_t::ignore</code> will silently ignore invalid byte sequences</li> </ul> </li> </ul> </div> <h3 id=jsonexceptiontype_error317>json.exception.type_error.317<a class=headerlink href=#jsonexceptiontype_error317 title="Permanent link">¶</a></h3> <p>The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw <code>true</code> or <code>null</code> <abbr title="JavaScript Object Notation">JSON</abbr> object cannot be serialized to <abbr title="Binary JSON">BSON</abbr>)</p> <div class="admonition failure"> <p class=admonition-title>Example messages</p> <p>Serializing <code class=highlight><span class=kc>null</span></code> to <abbr title="Binary JSON">BSON</abbr>: <div class=highlight><pre><span></span><code>[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is null
|
||||
</code></pre></div> Serializing <code class=highlight><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=mi>2</span><span class=p>,</span><span class=mi>3</span><span class=p>]</span></code> to <abbr title="Binary JSON">BSON</abbr>: <div class=highlight><pre><span></span><code>[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is array
|
||||
</code></pre></div></p> </div> <div class="admonition tip"> <p class=admonition-title>Tip</p> <p>Encapsulate the <abbr title="JavaScript Object Notation">JSON</abbr> value in an object. That is, instead of serializing <code class=highlight><span class=kc>true</span></code>, serialize <code class=highlight><span class=p>{</span><span class=nt>"value"</span><span class=p>:</span><span class=w> </span><span class=kc>true</span><span class=p>}</span></code></p> </div> <h2 id=out-of-range>Out of range<a class=headerlink href=#out-of-range title="Permanent link">¶</a></h2> <p>This exception is thrown in case a library function is called on an input parameter that exceeds the expected range, for instance in case of array indices or nonexisting object keys.</p> <p>Exceptions have ids 4xx.</p> <details class=example> <summary>Example</summary> <p>The following code shows how an <code>out_of_range</code> exception can be caught.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
|
||||
<span class=k>using</span><span class=w> </span><span class=n>json</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=n>nlohmann</span><span class=o>::</span><span class=n>json</span><span class=p>;</span>
|
||||
@@ -240,14 +240,13 @@ exception id: 308
|
||||
</code></pre></div> <p>Output:</p> <div class=highlight><pre><span></span><code>message: [json.exception.out_of_range.401] array index 4 is out of range
|
||||
exception id: 401
|
||||
</code></pre></div> </details> <h3 id=jsonexceptionout_of_range401>json.exception.out_of_range.401<a class=headerlink href=#jsonexceptionout_of_range401 title="Permanent link">¶</a></h3> <p>The provided array index <code>i</code> is larger than <code>size-1</code>.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>array index 3 is out of range
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range402>json.exception.out_of_range.402<a class=headerlink href=#jsonexceptionout_of_range402 title="Permanent link">¶</a></h3> <p>The special array index <code>-</code> in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>array index '-' (3) is out of range
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range403>json.exception.out_of_range.403<a class=headerlink href=#jsonexceptionout_of_range403 title="Permanent link">¶</a></h3> <p>The provided key was not found in the JSON object.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>key 'foo' not found
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range404>json.exception.out_of_range.404<a class=headerlink href=#jsonexceptionout_of_range404 title="Permanent link">¶</a></h3> <p>A reference token in a JSON Pointer could not be resolved.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>unresolved reference token 'foo'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range405>json.exception.out_of_range.405<a class=headerlink href=#jsonexceptionout_of_range405 title="Permanent link">¶</a></h3> <p>The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>JSON pointer has no parent
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range406>json.exception.out_of_range.406<a class=headerlink href=#jsonexceptionout_of_range406 title="Permanent link">¶</a></h3> <p>A parsed number could not be stored as without changing it to NaN or INF.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>number overflow parsing '10E1000'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range407>json.exception.out_of_range.407<a class=headerlink href=#jsonexceptionout_of_range407 title="Permanent link">¶</a></h3> <p>UBJSON only support integer numbers up to 9223372036854775807.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>number overflow serializing '9223372036854775808'
|
||||
</code></pre></div> </div> <div class="admonition note"> <p class=admonition-title>Note</p> <p>Since version 3.9.0, integer numbers beyond int64 are serialized as high-precision UBJSON numbers, and this exception does not further occur. </p> </div> <h3 id=jsonexceptionout_of_range408>json.exception.out_of_range.408<a class=headerlink href=#jsonexceptionout_of_range408 title="Permanent link">¶</a></h3> <p>The size (following <code>#</code>) of an UBJSON array or object exceeds the maximal capacity.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>excessive array size: 8658170730974374167
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range409>json.exception.out_of_range.409<a class=headerlink href=#jsonexceptionout_of_range409 title="Permanent link">¶</a></h3> <p>Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>BSON key cannot contain code point U+0000 (at byte 2)
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range402>json.exception.out_of_range.402<a class=headerlink href=#jsonexceptionout_of_range402 title="Permanent link">¶</a></h3> <p>The special array index <code>-</code> in a <abbr title="JavaScript Object Notation">JSON</abbr> Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>array index '-' (3) is out of range
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range403>json.exception.out_of_range.403<a class=headerlink href=#jsonexceptionout_of_range403 title="Permanent link">¶</a></h3> <p>The provided key was not found in the <abbr title="JavaScript Object Notation">JSON</abbr> object.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>key 'foo' not found
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range404>json.exception.out_of_range.404<a class=headerlink href=#jsonexceptionout_of_range404 title="Permanent link">¶</a></h3> <p>A reference token in a <abbr title="JavaScript Object Notation">JSON</abbr> Pointer could not be resolved.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>unresolved reference token 'foo'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range405>json.exception.out_of_range.405<a class=headerlink href=#jsonexceptionout_of_range405 title="Permanent link">¶</a></h3> <p>The <abbr title="JavaScript Object Notation">JSON</abbr> Patch operations 'remove' and 'add' can not be applied to the root element of the <abbr title="JavaScript Object Notation">JSON</abbr> value.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>JSON pointer has no parent
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range406>json.exception.out_of_range.406<a class=headerlink href=#jsonexceptionout_of_range406 title="Permanent link">¶</a></h3> <p>A parsed number could not be stored as without changing it to <abbr title="Not a Number">NaN</abbr> or INF.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>number overflow parsing '10E1000'
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range407>json.exception.out_of_range.407<a class=headerlink href=#jsonexceptionout_of_range407 title="Permanent link">¶</a></h3> <p>This exception previously indicated that the <abbr title="Universal Binary JSON">UBJSON</abbr> and <abbr title="Binary JSON">BSON</abbr> binary formats did not support integer numbers greater than 9223372036854775807 due to limitations in the implemented mapping. However, these limitations have since been resolved, and this exception no longer occurs.</p> <div class="admonition success"> <p class=admonition-title>Exception cannot occur any more</p> <ul> <li>Since version 3.9.0, integer numbers beyond int64 are serialized as high-precision <abbr title="Universal Binary JSON">UBJSON</abbr> numbers.</li> <li>Since version 3.12.0, integer numbers beyond int64 are serialized as uint64 <abbr title="Binary JSON">BSON</abbr> numbers.</li> </ul> </div> <h3 id=jsonexceptionout_of_range408>json.exception.out_of_range.408<a class=headerlink href=#jsonexceptionout_of_range408 title="Permanent link">¶</a></h3> <p>The size (following <code>#</code>) of an <abbr title="Universal Binary JSON">UBJSON</abbr> array or object exceeds the maximal capacity.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>excessive array size: 8658170730974374167
|
||||
</code></pre></div> </div> <h3 id=jsonexceptionout_of_range409>json.exception.out_of_range.409<a class=headerlink href=#jsonexceptionout_of_range409 title="Permanent link">¶</a></h3> <p>Key identifiers to be serialized to <abbr title="Binary JSON">BSON</abbr> cannot contain code point U+0000, since the key is stored as zero-terminated c-string.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <div class=highlight><pre><span></span><code>BSON key cannot contain code point U+0000 (at byte 2)
|
||||
</code></pre></div> </div> <h2 id=further-exceptions>Further exceptions<a class=headerlink href=#further-exceptions title="Permanent link">¶</a></h2> <p>This exception is thrown in case of errors that cannot be classified with the other exception types.</p> <p>Exceptions have ids 5xx.</p> <details class=example> <summary>Example</summary> <p>The following code shows how an <code>other_error</code> exception can be caught.</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><iostream></span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><nlohmann/json.hpp></span>
|
||||
|
||||
@@ -280,5 +279,5 @@ exception id: 401
|
||||
<span class=p>}</span>
|
||||
</code></pre></div> <p>Output:</p> <div class=highlight><pre><span></span><code>message: [json.exception.other_error.501] unsuccessful: {"op":"test","path":"/best_biscuit/name","value":"Choco Leibniz"}
|
||||
exception id: 501
|
||||
</code></pre></div> </details> <h3 id=jsonexceptionother_error501>json.exception.other_error.501<a class=headerlink href=#jsonexceptionother_error501 title="Permanent link">¶</a></h3> <p>A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Executing <code class=highlight><span class=p>{</span><span class=nt>"op"</span><span class=p>:</span><span class=s2>"test"</span><span class=p>,</span><span class=w> </span><span class=nt>"path"</span><span class=p>:</span><span class=s2>"/baz"</span><span class=p>,</span><span class=w> </span><span class=nt>"value"</span><span class=p>:</span><span class=s2>"bar"</span><span class=p>}</span></code> on <code class=highlight><span class=p>{</span><span class=nt>"baz"</span><span class=p>:</span><span class=w> </span><span class=s2>"qux"</span><span class=p>}</span></code>:</p> <div class=highlight><pre><span></span><code>[json.exception.other_error.501] unsuccessful: {"op":"test","path":"/baz","value":"bar"}
|
||||
</code></pre></div> </div> <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">January 10, 2025</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 © 2013 - 2024 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 496 512"><!-- Font Awesome Free 6.7.1 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 2024 Fonticons, Inc.--><path d="M165.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.9M244.8 8C106.1 8 0 113.3 0 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.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.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 6.7.1 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 2024 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.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5m282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9z"/></svg> </a> <a href=https://www.xing.com/profile/Niels_Lohmann target=_blank rel=noopener title=www.xing.com class=md-social__link> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 384 512"><!-- Font Awesome Free 6.7.1 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 2024 Fonticons, Inc.--><path d="M162.7 210c-1.8 3.3-25.2 44.4-70.1 123.5-4.9 8.3-10.8 12.5-17.7 12.5H9.8c-7.7 0-12.1-7.5-8.5-14.4l69-121.3q.3 0 0-.3l-43.9-75.6c-4.3-7.8.3-14.1 8.5-14.1H100c7.3 0 13.3 4.1 18 12.2zM382.6 46.1l-144 253v.3L330.2 466c3.9 7.1.2 14.1-8.5 14.1h-65.2c-7.6 0-13.6-4-18-12.2l-92.4-168.5c3.3-5.8 51.5-90.8 144.8-255.2 4.6-8.1 10.4-12.2 17.5-12.2h65.7c8 0 12.3 6.7 8.5 14.1"/></svg> </a> <a href=https://www.paypaLine truncated
|
||||
</code></pre></div> </details> <h3 id=jsonexceptionother_error501>json.exception.other_error.501<a class=headerlink href=#jsonexceptionother_error501 title="Permanent link">¶</a></h3> <p>A <abbr title="JavaScript Object Notation">JSON</abbr> Patch operation 'test' failed. The unsuccessful operation is also printed.</p> <div class="admonition failure"> <p class=admonition-title>Example message</p> <p>Executing <code class=highlight><span class=p>{</span><span class=nt>"op"</span><span class=p>:</span><span class=s2>"test"</span><span class=p>,</span><span class=w> </span><span class=nt>"path"</span><span class=p>:</span><span class=s2>"/baz"</span><span class=p>,</span><span class=w> </span><span class=nt>"value"</span><span class=p>:</span><span class=s2>"bar"</span><span class=p>}</span></code> on <code class=highlight><span class=p>{</span><span class=nt>"baz"</span><span class=p>:</span><span class=w> </span><span class=s2>"qux"</span><span class=p>}</span></code>:</p> <div class=highlight><pre><span></span><code>[json.exception.other_error.501] unsuccessful: {"op":"test","path":"/baz","value":"bar"}
|
||||
</code></pre></div> </div> <!-- 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">January 17, 2025</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 © 2013-2025 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 496 512"><!-- Font Awesome Free 6.7.1 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 2024 Fonticons, Inc.--><path d="M165.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.9M244.8 8C106.1 8 0 113.3 0 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.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.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 6.7.1 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 2024 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.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5m282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9z"/></svg> </a> <a href="https://www.xing.com/profile/Niels_Lohmann" target="_blank" rel="noopener" title="www.xing.com" class="md-social__link"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 384 512"><!-- Font Awesome Free 6.7.1 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 2024 Fonticons, Inc.--><path d="M162.7 210c-1.8 3.3-25.2 44.4-70.1 123.5-4.9 8.3-10.8 12.5-17.7 12.5H9.8c-7.7 0-12.1-7.5-8.5-14.4l69-121.3q.3 0 0-.3l-43.9-75.6c-4.3-7.8.3-14.1 8.5-14.1H100c7.3 0 13.3 4.1 18 12.2zM382.6 46.1l-144 253v.3L330.2 466c3.9 7.1.2 14.1-8.5 14.1h-65.2c-7.6 0-13.6-4-18-12.2l-92.4-168.5c3.3-5Line truncated
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href=https://json.nlohmann.me/home/faq/ rel=canonical><link href=../code_of_conduct/ rel=prev><link href=../exceptions/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>FAQ - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#frequently-asked-questions-faq class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> FAQ </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0Line truncated
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/faq/" rel="canonical"><link href=../license/ rel=prev><link href=../exceptions/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>FAQ - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.61a430c9.css"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#frequently-asked-questions-faq class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> FAQ </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-search data-md-Line truncated
|
||||
</code></pre></div> <p>and</p> <div class=highlight><pre><span></span><code><span class=n>json</span><span class=w> </span><span class=nf>j</span><span class=p>(</span><span class=nb>true</span><span class=p>);</span>
|
||||
</code></pre></div> <p>yield different results (<code class=highlight><span class=p>[</span><span class=kc>true</span><span class=p>]</span></code> vs. <code class=highlight><span class=kc>true</span></code>)?</p> </div> <p>This is a known issue, and -- even worse -- the behavior differs between GCC and Clang. The "culprit" for this is the library's constructor overloads for initializer lists to allow syntax like</p> <div class=highlight><pre><span></span><code><span class=n>json</span><span class=w> </span><span class=n>array</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>{</span><span class=mi>1</span><span class=p>,</span><span class=w> </span><span class=mi>2</span><span class=p>,</span><span class=w> </span><span class=mi>3</span><span class=p>,</span><span class=w> </span><span class=mi>4</span><span class=p>};</span>
|
||||
</code></pre></div> <p>yield different results (<code class=highlight><span class=p>[</span><span class=kc>true</span><span class=p>]</span></code> vs. <code class=highlight><span class=kc>true</span></code>)?</p> </div> <p>This is a known issue, and -- even worse -- the behavior differs between <abbr title="GNU Compiler Collection">GCC</abbr> and Clang. The "culprit" for this is the library's constructor overloads for initializer lists to allow syntax like</p> <div class=highlight><pre><span></span><code><span class=n>json</span><span class=w> </span><span class=n>array</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>{</span><span class=mi>1</span><span class=p>,</span><span class=w> </span><span class=mi>2</span><span class=p>,</span><span class=w> </span><span class=mi>3</span><span class=p>,</span><span class=w> </span><span class=mi>4</span><span class=p>};</span>
|
||||
</code></pre></div> <p>for arrays and</p> <div class=highlight><pre><span></span><code><span class=n>json</span><span class=w> </span><span class=n>object</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>{{</span><span class=s>"one"</span><span class=p>,</span><span class=w> </span><span class=mi>1</span><span class=p>},</span><span class=w> </span><span class=p>{</span><span class=s>"two"</span><span class=p>,</span><span class=w> </span><span class=mi>2</span><span class=p>}};</span><span class=w> </span>
|
||||
</code></pre></div> <p>for objects.</p> <div class="admonition tip"> <p class=admonition-title>Tip</p> <p>To avoid any confusion and ensure portable code, <strong>do not</strong> use brace initialization with the types <code>basic_json</code>, <code>json</code>, or <code>ordered_json</code> unless you want to create an object or array as shown in the examples above.</p> </div> <h2 id=limitations>Limitations<a class=headerlink href=#limitations title="Permanent link">¶</a></h2> <h3 id=relaxed-parsing>Relaxed parsing<a class=headerlink href=#relaxed-parsing title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Can you add an option to ignore trailing commas?</p> </div> <p>This library does not support any feature which would jeopardize interoperability.</p> <h3 id=parse-errors-reading-non-ascii-characters>Parse errors reading non-ASCII characters<a class=headerlink href=#parse-errors-reading-non-ascii-characters title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Questions</p> <ul> <li>Why is the parser complaining about a Chinese character?</li> <li>Does the library support Unicode?</li> <li>I get an exception <code>[json.exception.parse_error.101] parse error at line 1, column 53: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"Testé$')"</code></li> </ul> </div> <p>The library supports <strong>Unicode input</strong> as follows:</p> <ul> <li>Only <strong>UTF-8</strong> encoded input is supported which is the default encoding for JSON according to <a href=https://tools.ietf.org/html/rfc8259.html#section-8.1>RFC 8259</a>.</li> <li><code>std::u16string</code> and <code>std::u32string</code> can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers.</li> <li>Other encodings such as Latin-1 or ISO 8859-1 are <strong>not</strong> supported and will yield parse or serialization errors.</li> <li><a href=http://www.unicode.org/faq/private_use.html#nonchar1>Unicode noncharacters</a> will not be replaced by the library.</li> <li>Invalid surrogates (e.g., incomplete pairs such as <code>\uDEAD</code>) will yield parse errors.</li> <li>The strings stored in the library are UTF-8 encoded. When using the default string type (<code>std::string</code>), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.</li> <li>When you store strings with different encodings in the library, calling <a href=https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5><code>dump()</code></a> may throw an exception unless <code>json::error_handler_t::replace</code> or <code>json::error_handler_t::ignore</code> are used as error handlers.</li> </ul> <p>In most cases, the parser is right to complain, because the input is not UTF-8 encoded. This is especially true for Microsoft Windows where Latin-1 or ISO 8859-1 is often the standard encoding.</p> <h3 id=wide-string-handling>Wide string handling<a class=headerlink href=#wide-string-handling title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Why are wide strings (e.g., <code>std::wstring</code>) dumped as arrays of numbers?</p> </div> <p>As described <a href=#parse-errors-reading-non-ascii-characters>above</a>, the library assumes UTF-8 as encoding. To store a wide string, you need to change the encoding.</p> <div class="admonition example"> <p class=admonition-title>Example</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><codecvt></span><span class=c1> // codecvt_utf8</span>
|
||||
</code></pre></div> <p>for objects.</p> <div class="admonition tip"> <p class=admonition-title>Tip</p> <p>To avoid any confusion and ensure portable code, <strong>do not</strong> use brace initialization with the types <code>basic_json</code>, <code>json</code>, or <code>ordered_json</code> unless you want to create an object or array as shown in the examples above.</p> </div> <h2 id=limitations>Limitations<a class=headerlink href=#limitations title="Permanent link">¶</a></h2> <h3 id=relaxed-parsing>Relaxed parsing<a class=headerlink href=#relaxed-parsing title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Can you add an option to ignore trailing commas?</p> </div> <p>This library does not support any feature which would jeopardize interoperability.</p> <h3 id=parse-errors-reading-non-ascii-characters>Parse errors reading non-<abbr title="American Standard Code for Information Interchange">ASCII</abbr> characters<a class=headerlink href=#parse-errors-reading-non-ascii-characters title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Questions</p> <ul> <li>Why is the parser complaining about a Chinese character?</li> <li>Does the library support Unicode?</li> <li>I get an exception <code>[json.exception.parse_error.101] parse error at line 1, column 53: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"Testé$')"</code></li> </ul> </div> <p>The library supports <strong>Unicode input</strong> as follows:</p> <ul> <li>Only <strong><abbr title="Unicode Transformation Format">UTF</abbr>-8</strong> encoded input is supported which is the default encoding for <abbr title="JavaScript Object Notation">JSON</abbr> according to <a href="https://tools.ietf.org/html/rfc8259.html#section-8.1"><abbr title="Request for Comments">RFC</abbr> 8259</a>.</li> <li><code>std::u16string</code> and <code>std::u32string</code> can be parsed, assuming <abbr title="Unicode Transformation Format">UTF</abbr>-16 and <abbr title="Unicode Transformation Format">UTF</abbr>-32 encoding, respectively. These encodings are not supported when reading from files or other input containers.</li> <li>Other encodings such as Latin-1 or <abbr title="International Organization for Standardization">ISO</abbr> 8859-1 are <strong>not</strong> supported and will yield parse or serialization errors.</li> <li><a href="http://www.unicode.org/faq/private_use.html#nonchar1">Unicode noncharacters</a> will not be replaced by the library.</li> <li>Invalid surrogates (e.g., incomplete pairs such as <code>\uDEAD</code>) will yield parse errors.</li> <li>The strings stored in the library are <abbr title="Unicode Transformation Format">UTF</abbr>-8 encoded. When using the default string type (<code>std::string</code>), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.</li> <li>When you store strings with different encodings in the library, calling <a href="https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5"><code>dump()</code></a> may throw an exception unless <code>json::error_handler_t::replace</code> or <code>json::error_handler_t::ignore</code> are used as error handlers.</li> </ul> <p>In most cases, the parser is right to complain, because the input is not <abbr title="Unicode Transformation Format">UTF</abbr>-8 encoded. This is especially true for Microsoft Windows where Latin-1 or <abbr title="International Organization for Standardization">ISO</abbr> 8859-1 is often the standard encoding.</p> <h3 id=wide-string-handling>Wide string handling<a class=headerlink href=#wide-string-handling title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Why are wide strings (e.g., <code>std::wstring</code>) dumped as arrays of numbers?</p> </div> <p>As described <a href=#parse-errors-reading-non-ascii-characters>above</a>, the library assumes <abbr title="Unicode Transformation Format">UTF</abbr>-8 as encoding. To store a wide string, you need to change the encoding.</p> <div class="admonition example"> <p class=admonition-title>Example</p> <div class=highlight><pre><span></span><code><span class=cp>#include</span><span class=w> </span><span class=cpf><codecvt></span><span class=c1> // codecvt_utf8</span>
|
||||
<span class=cp>#include</span><span class=w> </span><span class=cpf><locale></span><span class=c1> // wstring_convert</span>
|
||||
|
||||
<span class=c1>// encoding function</span>
|
||||
@@ -23,7 +23,7 @@
|
||||
<span class=w> </span><span class=nt>"encoded"</span><span class=p>:</span><span class=w> </span><span class=s2>"車B1234 こんにちは"</span><span class=p>,</span>
|
||||
<span class=w> </span><span class=nt>"original"</span><span class=p>:</span><span class=w> </span><span class=p>[</span><span class=mi>36554</span><span class=p>,</span><span class=w> </span><span class=mi>66</span><span class=p>,</span><span class=w> </span><span class=mi>49</span><span class=p>,</span><span class=w> </span><span class=mi>50</span><span class=p>,</span><span class=w> </span><span class=mi>51</span><span class=p>,</span><span class=w> </span><span class=mi>52</span><span class=p>,</span><span class=w> </span><span class=mi>32</span><span class=p>,</span><span class=w> </span><span class=mi>12371</span><span class=p>,</span><span class=w> </span><span class=mi>12435</span><span class=p>,</span><span class=w> </span><span class=mi>12395</span><span class=p>,</span><span class=w> </span><span class=mi>12385</span><span class=p>,</span><span class=w> </span><span class=mi>12399</span><span class=p>]</span>
|
||||
<span class=p>}</span>
|
||||
</code></pre></div> </div> <h2 id=exceptions>Exceptions<a class=headerlink href=#exceptions title="Permanent link">¶</a></h2> <h3 id=parsing-without-exceptions>Parsing without exceptions<a class=headerlink href=#parsing-without-exceptions title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Is it possible to indicate a parse error without throwing an exception?</p> </div> <p>Yes, see <a href=../../features/parsing/parse_exceptions/ >Parsing and exceptions</a>.</p> <h3 id=key-name-in-exceptions>Key name in exceptions<a class=headerlink href=#key-name-in-exceptions title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Can I get the key of the object item that caused an exception?</p> </div> <p>Yes, you can. Please define the symbol <a href=../../api/macros/json_diagnostics/ ><code>JSON_DIAGNOSTICS</code></a> to get <a href=../exceptions/#extended-diagnostic-messages>extended diagnostics messages</a>.</p> <h2 id=serialization-issues>Serialization issues<a class=headerlink href=#serialization-issues title="Permanent link">¶</a></h2> <h3 id=number-precision>Number precision<a class=headerlink href=#number-precision title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <ul> <li>It seems that precision is lost when serializing a double.</li> <li>Can I change the precision for floating-point serialization?</li> </ul> </div> <p>The library uses <code>std::numeric_limits<number_float_t>::digits10</code> (15 for IEEE <code>double</code>s) digits for serialization. This value is sufficient to guarantee roundtripping. If one uses more than this number of digits of precision, then string -> value -> string is not guaranteed to round-trip.</p> <div class="admonition quote"> <p class=admonition-title><a href=https://en.cppreference.com/w/cpp/types/numeric_limits/digits10>cppreference.com</a></p> <p>The value of <code>std::numeric_limits<T>::digits10</code> is the number of base-10 digits that can be represented by the type T without change, that is, any number with this many significant decimal digits can be converted to a value of type T and back to decimal form, without change due to rounding or overflow. </p> </div> <div class="admonition tip"> <p class=admonition-title>Tip</p> <p>The website <a href=https://float.exposed>https://float.exposed</a> gives a good insight into the internal storage of floating-point numbers.</p> </div> <p>See <a href=../../features/types/number_handling/#number-serialization>this section</a> on the library's number handling for more information.</p> <h2 id=compilation-issues>Compilation issues<a class=headerlink href=#compilation-issues title="Permanent link">¶</a></h2> <h3 id=android-sdk>Android SDK<a class=headerlink href=#android-sdk title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Why does the code not compile with Android SDK?</p> </div> <p>Android defaults to using very old compilers and C++ libraries. To fix this, add the following to your <code>Application.mk</code>. This will switch to the LLVM C++ library, the Clang compiler, and enable C++11 and other features disabled by default.</p> <div class=highlight><pre><span></span><code><span class=na>APP_STL</span><span class=w> </span><span class=o>:</span><span class=s>= c++_shared</span>
|
||||
</code></pre></div> </div> <h2 id=exceptions>Exceptions<a class=headerlink href=#exceptions title="Permanent link">¶</a></h2> <h3 id=parsing-without-exceptions>Parsing without exceptions<a class=headerlink href=#parsing-without-exceptions title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Is it possible to indicate a parse error without throwing an exception?</p> </div> <p>Yes, see <a href=../../features/parsing/parse_exceptions/ >Parsing and exceptions</a>.</p> <h3 id=key-name-in-exceptions>Key name in exceptions<a class=headerlink href=#key-name-in-exceptions title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Can I get the key of the object item that caused an exception?</p> </div> <p>Yes, you can. Please define the symbol <a href=../../api/macros/json_diagnostics/ ><code>JSON_DIAGNOSTICS</code></a> to get <a href=../exceptions/#extended-diagnostic-messages>extended diagnostics messages</a>.</p> <h2 id=serialization-issues>Serialization issues<a class=headerlink href=#serialization-issues title="Permanent link">¶</a></h2> <h3 id=number-precision>Number precision<a class=headerlink href=#number-precision title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <ul> <li>It seems that precision is lost when serializing a double.</li> <li>Can I change the precision for floating-point serialization?</li> </ul> </div> <p>The library uses <code>std::numeric_limits<number_float_t>::digits10</code> (15 for <abbr title="Institute of Electrical and Electronics Engineers">IEEE</abbr> <code>double</code>s) digits for serialization. This value is sufficient to guarantee roundtripping. If one uses more than this number of digits of precision, then string -> value -> string is not guaranteed to round-trip.</p> <div class="admonition quote"> <p class=admonition-title><a href="https://en.cppreference.com/w/cpp/types/numeric_limits/digits10">cppreference.com</a></p> <p>The value of <code>std::numeric_limits<T>::digits10</code> is the number of base-10 digits that can be represented by the type T without change, that is, any number with this many significant decimal digits can be converted to a value of type T and back to decimal form, without change due to rounding or overflow. </p> </div> <div class="admonition tip"> <p class=admonition-title>Tip</p> <p>The website <a href="https://float.exposed">https://float.exposed</a> gives a good insight into the internal storage of floating-point numbers.</p> </div> <p>See <a href=../../features/types/number_handling/#number-serialization>this section</a> on the library's number handling for more information.</p> <h2 id=compilation-issues>Compilation issues<a class=headerlink href=#compilation-issues title="Permanent link">¶</a></h2> <h3 id=android-sdk>Android <abbr title="Software Development Kit">SDK</abbr><a class=headerlink href=#android-sdk title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Question</p> <p>Why does the code not compile with Android <abbr title="Software Development Kit">SDK</abbr>?</p> </div> <p>Android defaults to using very old compilers and C++ libraries. To fix this, add the following to your <code>Application.mk</code>. This will switch to the LLVM C++ library, the Clang compiler, and enable C++11 and other features disabled by default.</p> <div class=highlight><pre><span></span><code><span class=na>APP_STL</span><span class=w> </span><span class=o>:</span><span class=s>= c++_shared</span>
|
||||
<span class=na>NDK_TOOLCHAIN_VERSION</span><span class=w> </span><span class=o>:</span><span class=s>= clang3.6</span>
|
||||
<span class=na>APP_CPPFLAGS +</span><span class=o>=</span><span class=w> </span><span class=s>-frtti -fexceptions</span>
|
||||
</code></pre></div> <p>The code compiles successfully with <a href="https://developer.android.com/ndk/index.html?hl=ml">Android NDK</a>, Revision 9 - 11 (and possibly later) and <a href=https://www.crystax.net/en/android/ndk>CrystaX's Android NDK</a> version 10.</p> <h3 id=missing-stl-function>Missing STL function<a class=headerlink href=#missing-stl-function title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Questions</p> <ul> <li>Why do I get a compilation error <code>'to_string' is not a member of 'std'</code> (or similarly, for <code>strtod</code> or <code>strtof</code>)?</li> <li>Why does the code not compile with MinGW or Android SDK?</li> </ul> </div> <p>This is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to <a href=http://tehsausage.com/mingw-to-string>this site</a> and <a href=https://github.com/nlohmann/json/issues/136>this discussion</a> for information on how to fix this bug. For Android NDK using <code>APP_STL := gnustl_static</code>, please refer to <a href=https://github.com/nlohmann/json/issues/219>this discussion</a>.</p> <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">January 10, 2025</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 © 2013 - 2024 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 496 512"><!-- Font Awesome Free 6.7.1 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 2024 Fonticons, Inc.--><path d="M165.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.9M244.8 8C106.1 8 0 113.3 0 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.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.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 6.7.1 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 2024 Fonticons, Inc.--><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 4Line truncated
|
||||
</code></pre></div> <p>The code compiles successfully with <a href="https://developer.android.com/ndk/index.html?hl=ml">Android <abbr title="Native Development Kit">NDK</abbr></a>, Revision 9 - 11 (and possibly later) and <a href="https://www.crystax.net/en/android/ndk">CrystaX's Android <abbr title="Native Development Kit">NDK</abbr></a> version 10.</p> <h3 id=missing-stl-function>Missing <abbr title="Standard Template Library">STL</abbr> function<a class=headerlink href=#missing-stl-function title="Permanent link">¶</a></h3> <div class="admonition question"> <p class=admonition-title>Questions</p> <ul> <li>Why do I get a compilation error <code>'to_string' is not a member of 'std'</code> (or similarly, for <code>strtod</code> or <code>strtof</code>)?</li> <li>Why does the code not compile with MinGW or Android <abbr title="Software Development Kit">SDK</abbr>?</li> </ul> </div> <p>This is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to <a href="http://tehsausage.com/mingw-to-string">this site</a> and <a href="https://github.com/nlohmann/json/issues/136">this discussion</a> for information on how to fix this bug. For Android <abbr title="Native Development Kit">NDK</abbr> using <code>APP_STL := gnustl_static</code>, please refer to <a href="https://github.com/nlohmann/json/issues/219">this discussion</a>.</p> <!-- 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">January 17, 2025</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 © 2013-2025 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 496 512"><!-- Font Awesome Free 6.7.1 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 2024 Fonticons, Inc.--><path d="M165.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.9M244.8 8C106.1 8 0 113.3 0 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.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.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-socialLine truncated
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href=https://json.nlohmann.me/home/license/ rel=canonical><link rel=prev href=../..><link href=../code_of_conduct/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>License - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#license class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> License </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0Line truncated
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/license/" rel="canonical"><link rel=prev href=../..><link href=../faq/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>License - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.61a430c9.css"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#license class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> License </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-search data-md-component=search role=diLine truncated
|
||||
@@ -1,10 +1,10 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href=https://json.nlohmann.me/home/releases/ rel=canonical><link href=../exceptions/ rel=prev><link href=../design_goals/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Releases - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#releases class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Releases </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5Line truncated
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/releases/" rel="canonical"><link href=../exceptions/ rel=prev><link href=../design_goals/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Releases - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.61a430c9.css"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#releases class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Releases </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-search data-md-coLine truncated
|
||||
<span class=w> </span><span class=n>std</span><span class=o>::</span><span class=n>cout</span><span class=w> </span><span class=o><<</span><span class=w> </span><span class=n>key</span><span class=w> </span><span class=o><<</span><span class=w> </span><span class=sc>':'</span><span class=w> </span><span class=o><<</span><span class=w> </span><span class=n>val</span><span class=w> </span><span class=o><<</span><span class=w> </span><span class=sc>'\n'</span><span class=p>;</span>
|
||||
<span class=p>}</span>
|
||||
</code></pre></div> #1388 #1391</p> </li> <li> <p>Added support for <strong>reading from <code>FILE*</code></strong> to support situations in which streams are nit available or would require too much RAM. #1370 #1392</p> </li> </ul> <h3 id=bug-fixes_6><img alt=🐛 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg title=:bug:> Bug Fixes<a class=headerlink href=#bug-fixes_6 title="Permanent link">¶</a></h3> <ul> <li>The <code>eofbit</code> was not set for input streams when the end of a stream was reached while parsing. #1340 #1343</li> <li>Fixed a bug in the SAX parser for BSON arrays.</li> </ul> <h3 id=improvements_3><img alt=⚡ class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/26a1.svg title=:zap:> Improvements<a class=headerlink href=#improvements_3 title="Permanent link">¶</a></h3> <ul> <li>Added support for Clang 5.0.1 (PS4 version). #1341 #1342</li> </ul> <h3 id=further-changes_5><img alt=🔨 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f528.svg title=:hammer:> Further Changes<a class=headerlink href=#further-changes_5 title="Permanent link">¶</a></h3> <ul> <li>Added a warning for implicit conversions to the documentation: It is not recommended to use implicit conversions when reading <strong>from</strong> a JSON value. Details about this recommendation can be found <a href=https://www.github.com/nlohmann/json/issues/958>here</a>. #1363</li> <li>Fixed typos in the documentation. #1329 #1380 #1382</li> <li>Fixed a C4800 warning. #1364</li> <li>Fixed a <code>-Wshadow</code> warning #1346</li> <li>Wrapped <code>std::snprintf</code> calls to avoid error in MSVC. #1337</li> <li>Added code to allow installation via Meson. #1345</li> </ul> <h3 id=deprecated-functions_6><img alt=🔥 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f525.svg title=:fire:> Deprecated functions<a class=headerlink href=#deprecated-functions_6 title="Permanent link">¶</a></h3> <p>This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):</p> <ul> <li>Function <a href=http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e><code>iterator_wrapper</code></a> are deprecated. Please use the member function <a href=http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd><code>items()</code></a> instead.</li> <li>Functions <a href=http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3><code>friend std::istream& operator<<(basic_json&, std::istream&)</code></a> and <a href=http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983><code>friend std::ostream& operator>>(const basic_json&, std::ostream&)</code></a> are deprecated. Please use <a href=http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8><code>friend std::istream& operator>>(std::istream&, basic_json&)</code></a> and <a href=http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405><code>friend operator<<(std::ostream&, const basic_json&)</code></a> instead.</li> </ul> <h2 id=v340>v3.4.0<a class=headerlink href=#v340 title="Permanent link">¶</a></h2> <div class="admonition summary"> <p class=admonition-title>Files</p> <ul> <li><a href=https://github.com/nlohmann/json/releases/download/v3.4.0/include.zip>include.zip</a> (132 KB)</li> <li><a href=https://github.com/nlohmann/json/releases/download/v3.4.0/include.zip.asc>include.zip.asc</a> (1 KB)</li> <li><a href=https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp>json.hpp</a> (689 KB)</li> <li><a href=https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp.asc>json.hpp.asc</a> (1 KB)</li> </ul> </div> <p>Release date: 2018-10-30 SHA-256: 63da6d1f22b2a7bb9e4ff7d6b255cf691a161ff49532dcc45d398a53e295835f (json.hpp), bfec46fc0cee01c509cf064d2254517e7fa80d1e7647fea37cf81d97c5682bdc (include.zip)</p> <h3 id=summary_7>Summary<a class=headerlink href=#summary_7 title="Permanent link">¶</a></h3> <p>This release introduces three new features:</p> <ul> <li><strong>BSON (Binary JSON)</strong> is next to CBOR, MessagePack, and UBJSON the fourth binary (de)serialization format supported by the library.</li> <li><strong>Adjustable error handlers for invalid Unicode</strong> allows to specify the behavior when invalid byte sequences are serialized.</li> <li><Line truncated
|
||||
</code></pre></div> #1388 #1391</p> </li> <li> <p>Added support for <strong>reading from <code>FILE*</code></strong> to support situations in which streams are nit available or would require too much RAM. #1370 #1392</p> </li> </ul> <h3 id=bug-fixes_6><img alt="🐛" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg" title=":bug:"> Bug Fixes<a class=headerlink href=#bug-fixes_6 title="Permanent link">¶</a></h3> <ul> <li>The <code>eofbit</code> was not set for input streams when the end of a stream was reached while parsing. #1340 #1343</li> <li>Fixed a bug in the <abbr title="Simple API for XML">SAX</abbr> parser for <abbr title="Binary JSON">BSON</abbr> arrays.</li> </ul> <h3 id=improvements_3><img alt="⚡" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/26a1.svg" title=":zap:"> Improvements<a class=headerlink href=#improvements_3 title="Permanent link">¶</a></h3> <ul> <li>Added support for Clang 5.0.1 (PS4 version). #1341 #1342</li> </ul> <h3 id=further-changes_5><img alt="🔨" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f528.svg" title=":hammer:"> Further Changes<a class=headerlink href=#further-changes_5 title="Permanent link">¶</a></h3> <ul> <li>Added a warning for implicit conversions to the documentation: It is not recommended to use implicit conversions when reading <strong>from</strong> a <abbr title="JavaScript Object Notation">JSON</abbr> value. Details about this recommendation can be found <a href="https://www.github.com/nlohmann/json/issues/958">here</a>. #1363</li> <li>Fixed typos in the documentation. #1329 #1380 #1382</li> <li>Fixed a C4800 warning. #1364</li> <li>Fixed a <code>-Wshadow</code> warning #1346</li> <li>Wrapped <code>std::snprintf</code> calls to avoid error in <abbr title="Microsoft Visual C++">MSVC</abbr>. #1337</li> <li>Added code to allow installation via Meson. #1345</li> </ul> <h3 id=deprecated-functions_6><img alt="🔥" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f525.svg" title=":fire:"> Deprecated functions<a class=headerlink href=#deprecated-functions_6 title="Permanent link">¶</a></h3> <p>This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):</p> <ul> <li>Function <a href="http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e"><code>iterator_wrapper</code></a> are deprecated. Please use the member function <a href="http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd"><code>items()</code></a> instead.</li> <li>Functions <a href="http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3"><code>friend std::istream& operator<<(basic_json&, std::istream&)</code></a> and <a href="http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983"><code>friend std::ostream& operator>>(const basic_json&, std::ostream&)</code></a> are deprecated. Please use <a href="http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8"><code>friend std::istream& operator>>(std::istream&, basic_json&)</code></a> and <a href="http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405"><code>friend operator<<(std::ostream&, const basic_json&)</code></a> instead.</li> </ul> <h2 id=v340>v3.4.0<a class=headerlink href=#v340 title="Permanent link">¶</a></h2> <div class="admonition summary"> <p class=admonition-title>Files</p> <ul> <li><a href="https://github.com/nlohmann/json/releases/download/v3.4.0/include.zip">include.zip</a> (132 KB)</li> <li><a href="https://github.com/nlohmann/json/releases/download/v3.4.0/include.zip.asc">include.zip.asc</a> (1 KB)</li> <li><a href="https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp">json.hpp</a> (689 KB)</li> <li><a href="https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp.asc">json.hpp.asc</a> (1 KB)</li> </ul> </div> <p>Release date: 2018-10-30 <abbr title="Secure Hash Algorithm">SHA</abbr>-256: 63da6d1f22b2a7bb9e4ff7d6b255cf691a161ff49532dcc45d398a53e295835f (json.hpp), bfec46fc0cee01c509cf064d2254517e7fa80d1e7647fea37cf81d97c5682bdc (include.zip)</p> <h3 id=summary_7>Summary<a class=headerlink href=#summary_7 title="Permanent link">¶</a></h3> <p>This release introduces three new features:<Line truncated
|
||||
</code></pre></div> <p>New code:</p> <div class=highlight><pre><span></span><code><span class=n>json</span><span class=w> </span><span class=n>j</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=n>json</span><span class=o>::</span><span class=n>parse</span><span class=p>(</span><span class=n>ss</span><span class=p>,</span><span class=w> </span><span class=n>cb</span><span class=p>);</span>
|
||||
</code></pre></div> <p>If no callback function is used, also the following code works:</p> <div class=highlight><pre><span></span><code><span class=n>json</span><span class=w> </span><span class=n>j</span><span class=p>;</span>
|
||||
<span class=n>j</span><span class=w> </span><span class=o><<</span><span class=w> </span><span class=n>ss</span><span class=p>;</span>
|
||||
</code></pre></div> <p>or</p> <div class=highlight><pre><span></span><code><span class=n>json</span><span class=w> </span><span class=n>j</span><span class=p>;</span>
|
||||
<span class=n>ss</span><span class=w> </span><span class=o>>></span><span class=w> </span><span class=n>j</span><span class=p>;</span>
|
||||
</code></pre></div> <h2 id=v211>v2.1.1<a class=headerlink href=#v211 title="Permanent link">¶</a></h2> <div class="admonition summary"> <p class=admonition-title>Files</p> <ul> <li><a href=https://github.com/nlohmann/json/releases/download/v2.1.1/json.hpp>json.hpp</a> (437 KB)</li> <li><a href=https://github.com/nlohmann/json/releases/download/v2.1.1/json.hpp.asc>json.hpp.asc</a> (1 KB)</li> </ul> </div> <p>Release date: 2017-02-25 SHA-256: faa2321beb1aa7416d035e7417fcfa59692ac3d8c202728f9bcc302e2d558f57</p> <h3 id=summary_15>Summary<a class=headerlink href=#summary_15 title="Permanent link">¶</a></h3> <p>This release <strong>fixes a locale-related bug in the parser</strong>. To do so, the whole number handling (lexer, parser, and also the serialization) have been overworked. Furthermore, a lot of small changes added up that were added to this release. All changes are backward-compatible.</p> <h3 id=changes_1>Changes<a class=headerlink href=#changes_1 title="Permanent link">¶</a></h3> <ul> <li><img alt=🐛 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg title=:bug:> Locales that have a different character than <code>.</code> as decimal separator (e.g., the Norwegian locale <code>nb_NO.UTF-8</code>) led to truncated number parsing or parse errors. The library now has been fixed to work with <strong>any locale</strong>. Note that <code>.</code> is still the only valid decimal separator for JSON input.</li> <li><img alt=🐛 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg title=:bug:> Numbers like <code>1.0</code> were correctly parsed as floating-point number, but serialized as integer (<code>1</code>). Now, <strong>floating-point numbers correctly round trip</strong>.</li> <li><img alt=🐛 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg title=:bug:> Parsing incorrect JSON numbers with leading 0 (<code>0123</code>) could yield a <a href=https://github.com/nlohmann/json/issues/452>buffer overflow</a>. This is fixed now by detecting such errors directly by the lexer.</li> <li><img alt=🐛 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg title=:bug:> Constructing a JSON value from a pointer was incorrectly interpreted as a Boolean; such code will now yield a compiler error.</li> <li><img alt=🐛 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg title=:bug:> Comparing a JSON number with <code>0</code> led to a comparison with <code>null</code>. This is fixed now.</li> <li><img alt=🐛 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg title=:bug:> All throw calls are now wrapped in macros.</li> <li><img alt=🔒 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f512.svg title=:lock:> Starting during the preparation of this release (since 8 February 2017), commits and released files are <strong>cryptographically signed</strong> with <a href="https://keybase.io/nlohmann/pgp_keys.asc?fingerprint=797167ae41c0a6d9232e48457f3cea63ae251b69">this GPG key</a>. Previous releases have also been signed.</li> <li><img alt=✨ class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/2728.svg title=:sparkles:> The parser for MessagePack and CBOR now supports an optional start index parameter to define a byte offset for the parser.</li> <li><img alt=🚨 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f6a8.svg title=:rotating_light:> Some more warnings have been fixed. With Clang, the code compiles <strong>without warnings</strong> with <code>-Weverything</code> (well, it needs <code>-Wno-documentation-unknown-command</code> and <code>-Wno-deprecated-declarations</code>, but you get the point).</li> <li><img alt=🔨 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f528.svg title=:hammer:> The code can be compiled easier with many Android NDKs by avoiding macros like <code>UINT8_MAX</code> which previously required defining a preprocessor macro for compilation.</li> <li><img alt=⚡ class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/26a1.svg title=:zap:> The unit tests now compile two times faster.</li> <li><img alt=➕ class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/2795.svg title=:heavy_plus_sign:> <a href=https://github.com/sakra/cotire>Cotire</a> is used to speed up the build.</li> <li><img alt=✏ class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/270f.svg title=:pencil2:> Fixed a lot of typos in the documentation.</li> <li><img alt=📝 class=twemoji src=https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f4dd.svg title=:memo:> Added a section to the README file that lists all used <a href=https://github.com/nlohmann/json#used-third-party-tools>Line truncated
|
||||
</code></pre></div> <h2 id=v211>v2.1.1<a class=headerlink href=#v211 title="Permanent link">¶</a></h2> <div class="admonition summary"> <p class=admonition-title>Files</p> <ul> <li><a href="https://github.com/nlohmann/json/releases/download/v2.1.1/json.hpp">json.hpp</a> (437 KB)</li> <li><a href="https://github.com/nlohmann/json/releases/download/v2.1.1/json.hpp.asc">json.hpp.asc</a> (1 KB)</li> </ul> </div> <p>Release date: 2017-02-25 <abbr title="Secure Hash Algorithm">SHA</abbr>-256: faa2321beb1aa7416d035e7417fcfa59692ac3d8c202728f9bcc302e2d558f57</p> <h3 id=summary_15>Summary<a class=headerlink href=#summary_15 title="Permanent link">¶</a></h3> <p>This release <strong>fixes a locale-related bug in the parser</strong>. To do so, the whole number handling (lexer, parser, and also the serialization) have been overworked. Furthermore, a lot of small changes added up that were added to this release. All changes are backward-compatible.</p> <h3 id=changes_1>Changes<a class=headerlink href=#changes_1 title="Permanent link">¶</a></h3> <ul> <li><img alt="🐛" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg" title=":bug:"> Locales that have a different character than <code>.</code> as decimal separator (e.g., the Norwegian locale <code>nb_NO.UTF-8</code>) led to truncated number parsing or parse errors. The library now has been fixed to work with <strong>any locale</strong>. Note that <code>.</code> is still the only valid decimal separator for <abbr title="JavaScript Object Notation">JSON</abbr> input.</li> <li><img alt="🐛" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg" title=":bug:"> Numbers like <code>1.0</code> were correctly parsed as floating-point number, but serialized as integer (<code>1</code>). Now, <strong>floating-point numbers correctly round trip</strong>.</li> <li><img alt="🐛" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg" title=":bug:"> Parsing incorrect <abbr title="JavaScript Object Notation">JSON</abbr> numbers with leading 0 (<code>0123</code>) could yield a <a href="https://github.com/nlohmann/json/issues/452">buffer overflow</a>. This is fixed now by detecting such errors directly by the lexer.</li> <li><img alt="🐛" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg" title=":bug:"> Constructing a <abbr title="JavaScript Object Notation">JSON</abbr> value from a pointer was incorrectly interpreted as a Boolean; such code will now yield a compiler error.</li> <li><img alt="🐛" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg" title=":bug:"> Comparing a <abbr title="JavaScript Object Notation">JSON</abbr> number with <code>0</code> led to a comparison with <code>null</code>. This is fixed now.</li> <li><img alt="🐛" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f41b.svg" title=":bug:"> All throw calls are now wrapped in macros.</li> <li><img alt="🔒" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f512.svg" title=":lock:"> Starting during the preparation of this release (since 8 February 2017), commits and released files are <strong>cryptographically signed</strong> with <a href="https://keybase.io/nlohmann/pgp_keys.asc?fingerprint=797167ae41c0a6d9232e48457f3cea63ae251b69">this GPG key</a>. Previous releases have also been signed.</li> <li><img alt="✨" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/2728.svg" title=":sparkles:"> The parser for MessagePack and <abbr title="Concise Binary Object Representation">CBOR</abbr> now supports an optional start index parameter to define a byte offset for the parser.</li> <li><img alt="🚨" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f6a8.svg" title=":rotating_light:"> Some more warnings have been fixed. With Clang, the code compiles <strong>without warnings</strong> with <code>-Weverything</code> (well, it needs <code>-Wno-documentation-unknown-command</code> and <code>-Wno-deprecated-declarations</code>, but you get the point).</li> <li><img alt="🔨" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/1f528.svg" title=":hammer:"> The code can be compiled easier with many Android NDKs by avoiding macros like <code>UINT8_MAX</code> which previously required defining a preprocessor macro for compilation.</li> <li><img alt="⚡" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdecked/twemoji@15.1.0/assets/svg/26a1.svg" title=":zap:"> The unit tests now compile two times faster.</li> <li><img alt="➕" class="twemoji" src="../../assets/external/cdn.jsdelivr.net/gh/jdeckedLine truncated
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href=https://json.nlohmann.me/home/sponsors/ rel=canonical><link href=../customers/ rel=prev><link href=../../features/arbitrary_types/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Sponsors - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#sponsors class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Sponsors </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6Line truncated
|
||||
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/sponsors/" rel="canonical"><link href=../customers/ rel=prev><link href=../../features/arbitrary_types/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.49"><title>Sponsors - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.6f8fc17f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.61a430c9.css"><style>:root{--md-text-font:"Roboto";--md-code-font:"JetBrains Mono"}</style><link rel=stylesheet href=../../css/custom.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#sponsors class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="JSON for Modern C++" class="md-header__button md-logo" aria-label="JSON for Modern C++" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> JSON for Modern C++ </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Sponsors </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-seaLine truncated
|
||||
Reference in new issue
Block a user