json/api/json_sax/index.html

3 lines
60 KiB
HTML
Raw Normal View History

<!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.5.3, mkdocs-material-9.4.7"><title>Overview - JSON for Modern C++</title><link rel=stylesheet href=../../assets/stylesheets/main.4b4a2bd9.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.356b1318.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> <script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script> <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.54Z"/></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 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></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_1> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_2 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 12 20 8.69Z"/></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_2> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_1 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 12c0-2.42-1.44-4.5-3.5-5.
<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 SAX 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> <hr> <div class=md-source-file> <small> Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">May 1, 2022</span> </small> </div> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var tab,labels=set.querySelector(".tabbed-labels");for(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> </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 8v12Z"/></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