This commit is contained in:
nlohmann committed 2025-05-22 10:54:49 +00:00
1 parent c5cf12c0d5
commit 90f3fa4749
237 files changed
+238 -238

No files matched your search

+1 -1
View File
@@ -1,3 +1,3 @@
<!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/api/json_sax/" rel="canonical"><link href=../json_pointer/to_string/ rel=prev><link href=binary/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.6.14"><title>Overview - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.342714a4.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=#nlohmannjson_sax 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> Overview </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 Line truncated
<span class=k>struct</span><span class=w> </span><span class=nc>json_sax</span><span class=p>;</span>
</code></pre></div> <p>This class describes the <abbr title="Simple API for XML">SAX</abbr> interface used by <a href=../basic_json/sax_parse/ >sax_parse</a>. Each function is called in different situations while the input is parsed. The boolean return value informs the parser whether to continue processing the input.</p> <h2 id=template-parameters>Template parameters<a class=headerlink href=#template-parameters title="Permanent link">&para;</a></h2> <dl> <dt><code>BasicJsonType</code></dt> <dd>a specialization of <a href=../basic_json/ ><code>basic_json</code></a></dd> </dl> <h2 id=member-types>Member types<a class=headerlink href=#member-types title="Permanent link">&para;</a></h2> <ul> <li><a href=../basic_json/number_integer_t/ ><strong>number_integer_t</strong></a> - <code>BasicJsonType</code>'s type for numbers (integer)</li> <li><a href=../basic_json/number_unsigned_t/ ><strong>number_unsigned_t</strong></a> - <code>BasicJsonType</code>'s type for numbers (unsigned)</li> <li><a href=../basic_json/number_float_t/ ><strong>number_float_t</strong></a> - <code>BasicJsonType</code>'s type for numbers (floating-point)</li> <li><a href=../basic_json/string_t/ ><strong>string_t</strong></a> - <code>BasicJsonType</code>'s type for strings</li> <li><a href=../basic_json/binary_t/ ><strong>binary_t</strong></a> - <code>BasicJsonType</code>'s type for binary arrays</li> </ul> <h2 id=member-functions>Member functions<a class=headerlink href=#member-functions title="Permanent link">&para;</a></h2> <ul> <li><a href=binary/ ><strong>binary</strong></a> (<em>virtual</em>) - a binary value was read</li> <li><a href=boolean/ ><strong>boolean</strong></a> (<em>virtual</em>) - a boolean value was read</li> <li><a href=end_array/ ><strong>end_array</strong></a> (<em>virtual</em>) - the end of an array was read</li> <li><a href=end_object/ ><strong>end_object</strong></a> (<em>virtual</em>) - the end of an object was read</li> <li><a href=key/ ><strong>key</strong></a> (<em>virtual</em>) - an object key was read</li> <li><a href=null/ ><strong>null</strong></a> (<em>virtual</em>) - a null value was read</li> <li><a href=number_float/ ><strong>number_float</strong></a> (<em>virtual</em>) - a floating-point number was read</li> <li><a href=number_integer/ ><strong>number_integer</strong></a> (<em>virtual</em>) - an integer number was read</li> <li><a href=number_unsigned/ ><strong>number_unsigned</strong></a> (<em>virtual</em>) - an unsigned integer number was read</li> <li><a href=parse_error/ ><strong>parse_error</strong></a> (<em>virtual</em>) - a parse error occurred</li> <li><a href=start_array/ ><strong>start_array</strong></a> (<em>virtual</em>) - the beginning of an array was read</li> <li><a href=start_object/ ><strong>start_object</strong></a> (<em>virtual</em>) - the beginning of an object was read</li> <li><a href=string/ ><strong>string</strong></a> (<em>virtual</em>) - a string value was read</li> </ul> <h2 id=version-history>Version history<a class=headerlink href=#version-history title="Permanent link">&para;</a></h2> <ul> <li>Added in version 3.2.0.</li> <li>Support for binary values (<code>binary_t</code>, <code>binary</code>) added in version 3.8.0.</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" title="May 22, 2025 06:01:46">May 22, 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 &copy; 2013-2025 Niels Lohmann </div> </div> <div class=md-social> <a href="hLine truncated
</code></pre></div> <p>This class describes the <abbr title="Simple API for XML">SAX</abbr> interface used by <a href=../basic_json/sax_parse/ >sax_parse</a>. Each function is called in different situations while the input is parsed. The boolean return value informs the parser whether to continue processing the input.</p> <h2 id=template-parameters>Template parameters<a class=headerlink href=#template-parameters title="Permanent link">&para;</a></h2> <dl> <dt><code>BasicJsonType</code></dt> <dd>a specialization of <a href=../basic_json/ ><code>basic_json</code></a></dd> </dl> <h2 id=member-types>Member types<a class=headerlink href=#member-types title="Permanent link">&para;</a></h2> <ul> <li><a href=../basic_json/number_integer_t/ ><strong>number_integer_t</strong></a> - <code>BasicJsonType</code>'s type for numbers (integer)</li> <li><a href=../basic_json/number_unsigned_t/ ><strong>number_unsigned_t</strong></a> - <code>BasicJsonType</code>'s type for numbers (unsigned)</li> <li><a href=../basic_json/number_float_t/ ><strong>number_float_t</strong></a> - <code>BasicJsonType</code>'s type for numbers (floating-point)</li> <li><a href=../basic_json/string_t/ ><strong>string_t</strong></a> - <code>BasicJsonType</code>'s type for strings</li> <li><a href=../basic_json/binary_t/ ><strong>binary_t</strong></a> - <code>BasicJsonType</code>'s type for binary arrays</li> </ul> <h2 id=member-functions>Member functions<a class=headerlink href=#member-functions title="Permanent link">&para;</a></h2> <ul> <li><a href=binary/ ><strong>binary</strong></a> (<em>virtual</em>) - a binary value was read</li> <li><a href=boolean/ ><strong>boolean</strong></a> (<em>virtual</em>) - a boolean value was read</li> <li><a href=end_array/ ><strong>end_array</strong></a> (<em>virtual</em>) - the end of an array was read</li> <li><a href=end_object/ ><strong>end_object</strong></a> (<em>virtual</em>) - the end of an object was read</li> <li><a href=key/ ><strong>key</strong></a> (<em>virtual</em>) - an object key was read</li> <li><a href=null/ ><strong>null</strong></a> (<em>virtual</em>) - a null value was read</li> <li><a href=number_float/ ><strong>number_float</strong></a> (<em>virtual</em>) - a floating-point number was read</li> <li><a href=number_integer/ ><strong>number_integer</strong></a> (<em>virtual</em>) - an integer number was read</li> <li><a href=number_unsigned/ ><strong>number_unsigned</strong></a> (<em>virtual</em>) - an unsigned integer number was read</li> <li><a href=parse_error/ ><strong>parse_error</strong></a> (<em>virtual</em>) - a parse error occurred</li> <li><a href=start_array/ ><strong>start_array</strong></a> (<em>virtual</em>) - the beginning of an array was read</li> <li><a href=start_object/ ><strong>start_object</strong></a> (<em>virtual</em>) - the beginning of an object was read</li> <li><a href=string/ ><strong>string</strong></a> (<em>virtual</em>) - a string value was read</li> </ul> <h2 id=version-history>Version history<a class=headerlink href=#version-history title="Permanent link">&para;</a></h2> <ul> <li>Added in version 3.2.0.</li> <li>Support for binary values (<code>binary_t</code>, <code>binary</code>) added in version 3.8.0.</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" title="May 22, 2025 10:39:39">May 22, 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 &copy; 2013-2025 Niels Lohmann </div> </div> <div class=md-social> <a href="hLine truncated