deploy: 54f6b3ef06
This commit is contained in:
1 parent
11a863958e
commit
40c9f42917
38 files changed
+564
-458
No files matched your search
@@ -203,7 +203,7 @@ packet-beta
|
||||
| 2-3 | `extra` | `uint16_t` | numbers: the number of integer digits (low byte) and fraction digits (high byte), 255 for more; objects: the number of their key hash index (1-based), or 0; otherwise 0 |
|
||||
| 4-7 | `off` | `uint32_t` | where the value starts: the first byte after a string's opening quote (or its position in the buffer of decoded strings), the first byte of a number or literal, the bracket of an array or object |
|
||||
| 8-11 | `len` | `uint32_t` | strings: the length after decoding; floats and literals: the length of the token; arrays and objects: the number of elements |
|
||||
| 12-15 | `next` | `uint32_t` | arrays and objects: the number of nodes of the subtree, including the node itself |
|
||||
| 12-15 | `next` | `uint32_t` | arrays and objects: the number of nodes of the subtree, including the node itself; strings with escapes: the position of the opening quote in the source plus one if the document was parsed with [`JSON_DIAGNOSTIC_POSITIONS`](../api/macros/json_diagnostic_positions.md), or 0 if it was not; all other values: 0 |
|
||||
|
||||
<p class="nj-table-caption" markdown>Fields of a node, by their byte offset within the 16-byte node. Integers use bytes 8-15 differently, see below.</p>
|
||||
|
||||
@@ -218,6 +218,12 @@ packet-beta
|
||||
step from element to element this way and skip whole subtrees in constant time.
|
||||
- **Offsets** are 32 bits wide, so a document is limited to 4294967279 bytes, 4 GiB minus 16 bytes (a margin below
|
||||
2^32 for positions one scanner step past the end of the text; `out_of_range.416`).
|
||||
- **Source positions** ([`JSON_DIAGNOSTIC_POSITIONS`](../api/macros/json_diagnostic_positions.md)) are derived by
|
||||
[`materialize()`](../api/basic_json_view/materialize.md) and cost almost nothing while parsing: the only work is
|
||||
storing the offset of the opening quote of a string with escapes in its `next`, which is otherwise unused. A
|
||||
scalar's range follows from `off` and its length, a string with escapes is scanned from its opening quote (`next`) to the closing one,
|
||||
and the end of an array or object is found by scanning from the end of its last element over whitespace, comments,
|
||||
and a trailing comma. `materialize()` hands these positions to the SAX builder of `parse()` in place of its lexer.
|
||||
- **Large objects** (128 members or more) get a hash index for their keys after parsing
|
||||
([`detail/view/object_index.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/object_index.hpp)):
|
||||
an open-addressing table whose slots hold the distance from the object's node to a key's node, so that a lookup does
|
||||
@@ -277,7 +283,7 @@ Images ([`save`](../api/basic_json_document/save.md) and [`load`](../api/basic_j
|
||||
the nodes as they are: a 64-byte header (the magic bytes `NJVI`, a format version, the sizes, and reserved bytes that
|
||||
must be zero), the nodes, the text, and the decoded strings. An edited document is first written in document order, as
|
||||
the parser would have written it (without links), and the numbers of the hash indexes are cleared, since `load`
|
||||
rebuilds the indexes. So a change of the node layout is a change of the image format: it must raise `image_version`,
|
||||
rebuilds the indexes. The flag *new* is kept, as these values have no position in the text. So a change of the node layout is a change of the image format: it must raise `image_version`,
|
||||
and `load` then rejects images of other versions (`parse_error.116`) instead of misreading them.
|
||||
|
||||
## Input adapters
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
16-31: "extra"
|
||||
32-63: "off"
|
||||
64-95: "len"
|
||||
96-127: "next"</code></pre> <p class=nj-caption>Layout of one 16-byte node of a <abbr title="JavaScript Object Notation">JSON</abbr> view index. Each row is 32 bits wide, and the numbers are the bit offsets of the fields <code>kind</code>, <code>flags</code>, <code>extra</code>, <code>off</code>, <code>len</code>, and <code>next</code>.</p> <table> <thead> <tr> <th>Bytes</th> <th>Field</th> <th>Type</th> <th>Contents</th> </tr> </thead> <tbody> <tr> <td>0</td> <td><code>kind</code></td> <td><code>uint8_t</code></td> <td>the type, numbered as <a href=../../api/basic_json/value_t/ ><code>value_t</code></a>: 0 null, 1 object, 2 array, 3 string, 4 boolean, 5 signed integer, 6 unsigned integer, 7 float; 10 for a link (see below). There is no node for a discarded value: a <a href=../../api/basic_json_view/is_discarded/ >discarded</a> view has none</td> </tr> <tr> <td>1</td> <td><code>flags</code></td> <td><code>uint8_t</code></td> <td>bits 0-1: where a string's bytes (or a number's token) are (0: the source text, 1: the buffer of decoded strings, for strings with escapes, 2: the edit buffer); bit 2: the value of a boolean; bit 3: moved, bit 4: new, bit 5: linked (see below)</td> </tr> <tr> <td>2-3</td> <td><code>extra</code></td> <td><code>uint16_t</code></td> <td>numbers: the number of integer digits (low byte) and fraction digits (high byte), 255 for more; objects: the number of their key hash index (1-based), or 0; otherwise 0</td> </tr> <tr> <td>4-7</td> <td><code>off</code></td> <td><code>uint32_t</code></td> <td>where the value starts: the first byte after a string's opening quote (or its position in the buffer of decoded strings), the first byte of a number or literal, the bracket of an array or object</td> </tr> <tr> <td>8-11</td> <td><code>len</code></td> <td><code>uint32_t</code></td> <td>strings: the length after decoding; floats and literals: the length of the token; arrays and objects: the number of elements</td> </tr> <tr> <td>12-15</td> <td><code>next</code></td> <td><code>uint32_t</code></td> <td>arrays and objects: the number of nodes of the subtree, including the node itself</td> </tr> </tbody> </table> <p class=nj-table-caption>Fields of a node, by their byte offset within the 16-byte node. Integers use bytes 8-15 differently, see below.</p> <ul> <li><strong>Integers</strong> keep their converted value in bytes 8-15 instead of <code>len</code> and <code>next</code>; the length of their token follows from the number of digits in <code>extra</code> (and the sign). Non-negative integers are unsigned integers, as with <a href=../../api/basic_json/parse/ ><code>parse</code></a>.</li> <li><strong>Floats</strong> keep only their token. The digit layout in <code>extra</code> lets the conversion read the digits without scanning the token again, and only when the value is read.</li> <li><strong>Object members</strong> are the node of the key (a string) followed by the nodes of the value.</li> <li><strong>Navigation</strong> needs no pointers: the elements of an array or object follow its node, and the node after a value's subtree is <code>next</code> nodes further for an array or object, and the next node otherwise (<code>document_data::after</code>). Views step from element to element this way and skip whole subtrees in constant time.</li> <li><strong>Offsets</strong> are 32 bits wide, so a document is limited to 4294967279 bytes, 4 <abbr title="Gibibyte (2^30 bytes)">GiB</abbr> minus 16 bytes (a margin below 2^32 for positions one scanner step past the end of the text; <code>out_of_range.416</code>).</li> <li><strong>Large objects</strong> (128 members or more) get a hash index for their keys after parsing (<a href="https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/object_index.hpp"><code>detail/view/object_index.hpp</code></a>): an open-addressing table whose slots hold the distance from the object's node to a key's node, so that a lookup does not compare every key. Of duplicate keys the table leads to the first, as a linear search does. The object's <code>extra</code> holds the number of its table. Only 65,535 tables fit into <code>extra</code>; objects beyond them are searched linearly.</li> </ul> <p>For example, <code class=highlight><span class=p>{</span><span class=nt>"a"</span><span class=p>:</span><span class=w> </span><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=w> </span><span class=mf>2.5</span><span class=p>]}</span></code> becomes five nodes. Each node's elements follow it, and <code>next</code> leads from an array or object past its subtree:</p> <pre class=mermaid><code>flowchart LR
|
||||
96-127: "next"</code></pre> <p class=nj-caption>Layout of one 16-byte node of a <abbr title="JavaScript Object Notation">JSON</abbr> view index. Each row is 32 bits wide, and the numbers are the bit offsets of the fields <code>kind</code>, <code>flags</code>, <code>extra</code>, <code>off</code>, <code>len</code>, and <code>next</code>.</p> <table> <thead> <tr> <th>Bytes</th> <th>Field</th> <th>Type</th> <th>Contents</th> </tr> </thead> <tbody> <tr> <td>0</td> <td><code>kind</code></td> <td><code>uint8_t</code></td> <td>the type, numbered as <a href=../../api/basic_json/value_t/ ><code>value_t</code></a>: 0 null, 1 object, 2 array, 3 string, 4 boolean, 5 signed integer, 6 unsigned integer, 7 float; 10 for a link (see below). There is no node for a discarded value: a <a href=../../api/basic_json_view/is_discarded/ >discarded</a> view has none</td> </tr> <tr> <td>1</td> <td><code>flags</code></td> <td><code>uint8_t</code></td> <td>bits 0-1: where a string's bytes (or a number's token) are (0: the source text, 1: the buffer of decoded strings, for strings with escapes, 2: the edit buffer); bit 2: the value of a boolean; bit 3: moved, bit 4: new, bit 5: linked (see below)</td> </tr> <tr> <td>2-3</td> <td><code>extra</code></td> <td><code>uint16_t</code></td> <td>numbers: the number of integer digits (low byte) and fraction digits (high byte), 255 for more; objects: the number of their key hash index (1-based), or 0; otherwise 0</td> </tr> <tr> <td>4-7</td> <td><code>off</code></td> <td><code>uint32_t</code></td> <td>where the value starts: the first byte after a string's opening quote (or its position in the buffer of decoded strings), the first byte of a number or literal, the bracket of an array or object</td> </tr> <tr> <td>8-11</td> <td><code>len</code></td> <td><code>uint32_t</code></td> <td>strings: the length after decoding; floats and literals: the length of the token; arrays and objects: the number of elements</td> </tr> <tr> <td>12-15</td> <td><code>next</code></td> <td><code>uint32_t</code></td> <td>arrays and objects: the number of nodes of the subtree, including the node itself; strings with escapes: the position of the opening quote in the source plus one if the document was parsed with <a href=../../api/macros/json_diagnostic_positions/ ><code>JSON_DIAGNOSTIC_POSITIONS</code></a>, or 0 if it was not; all other values: 0</td> </tr> </tbody> </table> <p class=nj-table-caption>Fields of a node, by their byte offset within the 16-byte node. Integers use bytes 8-15 differently, see below.</p> <ul> <li><strong>Integers</strong> keep their converted value in bytes 8-15 instead of <code>len</code> and <code>next</code>; the length of their token follows from the number of digits in <code>extra</code> (and the sign). Non-negative integers are unsigned integers, as with <a href=../../api/basic_json/parse/ ><code>parse</code></a>.</li> <li><strong>Floats</strong> keep only their token. The digit layout in <code>extra</code> lets the conversion read the digits without scanning the token again, and only when the value is read.</li> <li><strong>Object members</strong> are the node of the key (a string) followed by the nodes of the value.</li> <li><strong>Navigation</strong> needs no pointers: the elements of an array or object follow its node, and the node after a value's subtree is <code>next</code> nodes further for an array or object, and the next node otherwise (<code>document_data::after</code>). Views step from element to element this way and skip whole subtrees in constant time.</li> <li><strong>Offsets</strong> are 32 bits wide, so a document is limited to 4294967279 bytes, 4 <abbr title="Gibibyte (2^30 bytes)">GiB</abbr> minus 16 bytes (a margin below 2^32 for positions one scanner step past the end of the text; <code>out_of_range.416</code>).</li> <li><strong>Source positions</strong> (<a href=../../api/macros/json_diagnostic_positions/ ><code>JSON_DIAGNOSTIC_POSITIONS</code></a>) are derived by <a href=../../api/basic_json_view/materialize/ ><code>materialize()</code></a> and cost almost nothing while parsing: the only work is storing the offset of the opening quote of a string with escapes in its <code>next</code>, which is otherwise unused. A scalar's range follows from <code>off</code> and its length, a string with escapes is scanned from its opening quote (<code>next</code>) to the closing one, and the end of an array or object is found by scanning from the end of its last element over whitespace, comments, and a trailing comma. <code>materialize()</code> hands these positions to the <abbr title="Simple API for XML">SAX</abbr> builder of <code>parse()</code> in place of its lexer.</li> <li><strong>Large objects</strong> (128 members or more) get a hash index for their keys after parsing (<a href="https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/object_index.hpp"><code>detail/view/object_index.hpp</code></a>): an open-addressing table whose slots hold the distance froLine truncated
|
||||
n0["0: object<br>len 1, next 5"]
|
||||
n1["1: key a"]
|
||||
n2["2: array<br>len 2, next 3"]
|
||||
@@ -74,7 +74,7 @@
|
||||
e(["end"])
|
||||
n0 --> n1 --> n2 --> n3 --> n4 --> e
|
||||
n0 -. next .-> e
|
||||
n2 -. next .-> e</code></pre> <p class=nj-caption>The five nodes of <code class=highlight><span class=p>{</span><span class=nt>"a"</span><span class=p>:</span><span class=w> </span><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=w> </span><span class=mf>2.5</span><span class=p>]}</span></code> in document order. Solid arrows lead from each node to the one after it; dotted arrows show where <code>next</code> leads from the object and the array, past their subtrees.</p> <table> <thead> <tr> <th>Node</th> <th><code>kind</code></th> <th><code>extra</code></th> <th><code>off</code></th> <th><code>len</code></th> <th><code>next</code></th> </tr> </thead> <tbody> <tr> <td>0</td> <td>1 (object)</td> <td>0</td> <td>0</td> <td>1</td> <td>5</td> </tr> <tr> <td>1</td> <td>3 (string)</td> <td>0</td> <td>2</td> <td>1</td> <td>0</td> </tr> <tr> <td>2</td> <td>2 (array)</td> <td>0</td> <td>6</td> <td>2</td> <td>3</td> </tr> <tr> <td>3</td> <td>6 (unsigned integer)</td> <td>0x0001</td> <td>7</td> <td>-</td> <td>-</td> </tr> <tr> <td>4</td> <td>7 (float)</td> <td>0x0101</td> <td>10</td> <td>3</td> <td>0</td> </tr> </tbody> </table> <p class=nj-table-caption>Fields of the five nodes of <code class=highlight><span class=p>{</span><span class=nt>"a"</span><span class=p>:</span><span class=w> </span><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=w> </span><span class=mf>2.5</span><span class=p>]}</span></code>. <code>off</code> is the byte offset in the text, and - marks the bytes 8-15 that hold the integer's value instead of <code>len</code> and <code>next</code>.</p> <p>All <code>flags</code> are 0. The integer's bytes 8-15 hold its value, 1; its <code>extra</code> says it has one digit. The float's <code>extra</code> says it has one integer and one fraction digit, and its <code>len</code> is that of the token <code>2.5</code>.</p> <p>Editable documents (<a href=../../api/json_editable_document/ ><code>json_editable_document</code></a>, <a href="https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/edit.hpp"><code>detail/view/edit.hpp</code></a> and <a href="https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/edit_storage.hpp"><code>detail/view/edit_storage.hpp</code></a>) never write the source text and never move or resize the parsed index, so views stay valid while the document is edited:</p> <ul> <li>A new scalar is written over its node. Its text (a string, or the token of a number as <code>dump()</code> writes it) goes to the edit buffer, which <code>flags</code> bits 0-1 then name.</li> <li>An array or object whose elements change gets the flag <em>moved</em> (bit 3): its elements then live in a separate sequence (a header node, then the entries), whose number is in <code>off</code>. The entries are links (<code>kind</code> 10), whose bytes 8-15 hold the address of the value's node, so values never move.</li> <li>A node written by an edit gets the flag <em>new</em> (bit 4): it has no position in the source text.</li> <li>A value that an entry of such a sequence links to gets the flag <em>linked</em> (bit 5): its extent in the parsed layout (<code>next</code>) no longer matters, so a scalar can replace an array or object there in place.</li> <li>Views of read-only documents compile without any of this: how views walk the index is a template parameter (<code>navigation<Editable></code>).</li> </ul> <p>Images (<a href=../../api/basic_json_document/save/ ><code>save</code></a> and <a href=../../api/basic_json_document/load/ ><code>load</code></a>, <a href="https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/image.hpp"><code>detail/view/image.hpp</code></a>) store the nodes as they are: a 64-byte header (the magic bytes <code>NJVI</code>, a format version, the sizes, and reserved bytes that must be zero), the nodes, the text, and the decoded strings. An edited document is first written in document order, as the parser would have written it (without links), and the numbers of the hash indexes are cleared, since <code>load</code> rebuilds the indexes. So a change of the node layout is a change of the image format: it must raise <code>image_version</code>, and <code>load</code> then rejects images of other versions (<code>parse_error.116</code>) instead of misreading them.</p> <h2 id=input-adapters>Input adapters<a class=headerlink href=#input-adapters title="Permanent link">¶</a></h2> <p>Input is read via <strong>input adapters</strong> that abstract a source. Every input adapter provides this interface:</p> <div class=highlight><pre><span></span><code><span class=c1>/// the type of the characters in the input</span>
|
||||
n2 -. next .-> e</code></pre> <p class=nj-caption>The five nodes of <code class=highlight><span class=p>{</span><span class=nt>"a"</span><span class=p>:</span><span class=w> </span><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=w> </span><span class=mf>2.5</span><span class=p>]}</span></code> in document order. Solid arrows lead from each node to the one after it; dotted arrows show where <code>next</code> leads from the object and the array, past their subtrees.</p> <table> <thead> <tr> <th>Node</th> <th><code>kind</code></th> <th><code>extra</code></th> <th><code>off</code></th> <th><code>len</code></th> <th><code>next</code></th> </tr> </thead> <tbody> <tr> <td>0</td> <td>1 (object)</td> <td>0</td> <td>0</td> <td>1</td> <td>5</td> </tr> <tr> <td>1</td> <td>3 (string)</td> <td>0</td> <td>2</td> <td>1</td> <td>0</td> </tr> <tr> <td>2</td> <td>2 (array)</td> <td>0</td> <td>6</td> <td>2</td> <td>3</td> </tr> <tr> <td>3</td> <td>6 (unsigned integer)</td> <td>0x0001</td> <td>7</td> <td>-</td> <td>-</td> </tr> <tr> <td>4</td> <td>7 (float)</td> <td>0x0101</td> <td>10</td> <td>3</td> <td>0</td> </tr> </tbody> </table> <p class=nj-table-caption>Fields of the five nodes of <code class=highlight><span class=p>{</span><span class=nt>"a"</span><span class=p>:</span><span class=w> </span><span class=p>[</span><span class=mi>1</span><span class=p>,</span><span class=w> </span><span class=mf>2.5</span><span class=p>]}</span></code>. <code>off</code> is the byte offset in the text, and - marks the bytes 8-15 that hold the integer's value instead of <code>len</code> and <code>next</code>.</p> <p>All <code>flags</code> are 0. The integer's bytes 8-15 hold its value, 1; its <code>extra</code> says it has one digit. The float's <code>extra</code> says it has one integer and one fraction digit, and its <code>len</code> is that of the token <code>2.5</code>.</p> <p>Editable documents (<a href=../../api/json_editable_document/ ><code>json_editable_document</code></a>, <a href="https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/edit.hpp"><code>detail/view/edit.hpp</code></a> and <a href="https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/edit_storage.hpp"><code>detail/view/edit_storage.hpp</code></a>) never write the source text and never move or resize the parsed index, so views stay valid while the document is edited:</p> <ul> <li>A new scalar is written over its node. Its text (a string, or the token of a number as <code>dump()</code> writes it) goes to the edit buffer, which <code>flags</code> bits 0-1 then name.</li> <li>An array or object whose elements change gets the flag <em>moved</em> (bit 3): its elements then live in a separate sequence (a header node, then the entries), whose number is in <code>off</code>. The entries are links (<code>kind</code> 10), whose bytes 8-15 hold the address of the value's node, so values never move.</li> <li>A node written by an edit gets the flag <em>new</em> (bit 4): it has no position in the source text.</li> <li>A value that an entry of such a sequence links to gets the flag <em>linked</em> (bit 5): its extent in the parsed layout (<code>next</code>) no longer matters, so a scalar can replace an array or object there in place.</li> <li>Views of read-only documents compile without any of this: how views walk the index is a template parameter (<code>navigation<Editable></code>).</li> </ul> <p>Images (<a href=../../api/basic_json_document/save/ ><code>save</code></a> and <a href=../../api/basic_json_document/load/ ><code>load</code></a>, <a href="https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/image.hpp"><code>detail/view/image.hpp</code></a>) store the nodes as they are: a 64-byte header (the magic bytes <code>NJVI</code>, a format version, the sizes, and reserved bytes that must be zero), the nodes, the text, and the decoded strings. An edited document is first written in document order, as the parser would have written it (without links), and the numbers of the hash indexes are cleared, since <code>load</code> rebuilds the indexes. The flag <em>new</em> is kept, as these values have no position in the text. So a change of the node layout is a change of the image format: it must raise <code>image_version</code>, and <code>load</code> then rejects images of other versions (<code>parse_error.116</code>) instead of misreading them.</p> <h2 id=input-adapters>Input adapters<a class=headerlink href=#input-adapters title="Permanent link">¶</a></h2> <p>Input is read via <strong>input adapters</strong> that abstract a source. Every input adapter provides this interface:</p> <div class=highlight><pre><span></span><code><span class=c1>/// the type of the characters in the input</span>
|
||||
<span class=k>using</span><span class=w> </span><span class=n>char_type</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>...;</span>
|
||||
|
||||
<span class=c1>/// read a single character; returns std::char_traits<char_type>::eof() at the end of the input</span>
|
||||
@@ -138,4 +138,4 @@
|
||||
|
||||
<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> <p>found by argument-dependent lookup. The library defines them for standard types in <code>detail/conversions</code>; users add them for their own types, see <a href=../../features/arbitrary_types/ >Arbitrary Type Conversions</a>. The <a href=../../features/macros/ >serialization macros</a> generate these functions.</p> <h2 id=additional-features>Additional features<a class=headerlink href=#additional-features title="Permanent link">¶</a></h2> <ul> <li><a href=../../features/json_pointer/ ><abbr title="JavaScript Object Notation">JSON</abbr> Pointer</a> (class <code>json_pointer</code>) addresses values inside a tree. It is also the basis of <a href=../../features/json_patch/ ><abbr title="JavaScript Object Notation">JSON</abbr> Patch</a>.</li> <li><a href=../../features/binary_formats/ >Binary formats</a> are read by <code>binary_reader</code> and written by <code>binary_writer</code>.</li> <li>A <a href=../../api/basic_json/json_base_class_t/ >custom base class</a> can add members to every <a href=../../api/basic_json/ ><code>basic_json</code></a> value.</li> <li><a href=../../features/macros/ >Serialization macros</a> generate <code>to_json</code> and <code>from_json</code> functions for user-defined types.</li> </ul> <h2 id=details-namespace>Details namespace<a class=headerlink href=#details-namespace title="Permanent link">¶</a></h2> <p>Namespace <code>nlohmann::detail</code> contains all implementation details. It is not part of the public <abbr title="Application Programming Interface">API</abbr> and may change in any release. Besides the components above, it contains:</p> <ul> <li>type traits to detect the capabilities of user-defined types (<code>detail/meta/type_traits.hpp</code>),</li> <li>backports of C++14/17 features to C++11 (<code>detail/meta/cpp_future.hpp</code>), and</li> <li>helpers such as <code>string_concat</code> and <code>string_escape</code>.</li> </ul> <h2 id=see-also>See also<a class=headerlink href=#see-also title="Permanent link">¶</a></h2> <ul> <li><a href=../../api/basic_json/ ><code>basic_json</code></a> - the main class and all its member functions</li> <li><a href=../../api/adl_serializer/ ><code>adl_serializer</code></a> - customization point for type conversions</li> <li><a href=../../api/json_sax/ ><code>json_sax</code></a> - interface of the <abbr title="Simple API for XML">SAX</abbr> parser events</li> <li><a href=../../features/parsing/sax_interface/ ><abbr title="Simple API for XML">SAX</abbr> Interface</a> - how to consume parser events without building a <abbr title="Document Object Model">DOM</abbr></li> <li><a href=../../features/json_view/ >Zero-copy <abbr title="JavaScript Object Notation">JSON</abbr> views</a> - the flat node index that backs views and documents</li> <li><a href=../../features/types/template_parameters/ >Template Parameter Requirements</a> - the template parameters of basic_json</li> <li><a href=../../features/serialization/ >Serialization</a> - the output side of the library</li> <li><a href=../../features/namespace/ ><code>nlohmann</code> Namespace</a> - how the library namespace is structured</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="October 27, 2026 06:41:42 UTC">October 27, 2026</span> </span> </aside> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <nav class="md-footer__inner md-grid" aria-label=Footer> <a href=../design_goals/ class="md-footer__link md-footer__link--prev" aria-label="Previous: Design goals"> <div class="md-footer__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 Line truncated
|
||||
</code></pre></div> <p>found by argument-dependent lookup. The library defines them for standard types in <code>detail/conversions</code>; users add them for their own types, see <a href=../../features/arbitrary_types/ >Arbitrary Type Conversions</a>. The <a href=../../features/macros/ >serialization macros</a> generate these functions.</p> <h2 id=additional-features>Additional features<a class=headerlink href=#additional-features title="Permanent link">¶</a></h2> <ul> <li><a href=../../features/json_pointer/ ><abbr title="JavaScript Object Notation">JSON</abbr> Pointer</a> (class <code>json_pointer</code>) addresses values inside a tree. It is also the basis of <a href=../../features/json_patch/ ><abbr title="JavaScript Object Notation">JSON</abbr> Patch</a>.</li> <li><a href=../../features/binary_formats/ >Binary formats</a> are read by <code>binary_reader</code> and written by <code>binary_writer</code>.</li> <li>A <a href=../../api/basic_json/json_base_class_t/ >custom base class</a> can add members to every <a href=../../api/basic_json/ ><code>basic_json</code></a> value.</li> <li><a href=../../features/macros/ >Serialization macros</a> generate <code>to_json</code> and <code>from_json</code> functions for user-defined types.</li> </ul> <h2 id=details-namespace>Details namespace<a class=headerlink href=#details-namespace title="Permanent link">¶</a></h2> <p>Namespace <code>nlohmann::detail</code> contains all implementation details. It is not part of the public <abbr title="Application Programming Interface">API</abbr> and may change in any release. Besides the components above, it contains:</p> <ul> <li>type traits to detect the capabilities of user-defined types (<code>detail/meta/type_traits.hpp</code>),</li> <li>backports of C++14/17 features to C++11 (<code>detail/meta/cpp_future.hpp</code>), and</li> <li>helpers such as <code>string_concat</code> and <code>string_escape</code>.</li> </ul> <h2 id=see-also>See also<a class=headerlink href=#see-also title="Permanent link">¶</a></h2> <ul> <li><a href=../../api/basic_json/ ><code>basic_json</code></a> - the main class and all its member functions</li> <li><a href=../../api/adl_serializer/ ><code>adl_serializer</code></a> - customization point for type conversions</li> <li><a href=../../api/json_sax/ ><code>json_sax</code></a> - interface of the <abbr title="Simple API for XML">SAX</abbr> parser events</li> <li><a href=../../features/parsing/sax_interface/ ><abbr title="Simple API for XML">SAX</abbr> Interface</a> - how to consume parser events without building a <abbr title="Document Object Model">DOM</abbr></li> <li><a href=../../features/json_view/ >Zero-copy <abbr title="JavaScript Object Notation">JSON</abbr> views</a> - the flat node index that backs views and documents</li> <li><a href=../../features/types/template_parameters/ >Template Parameter Requirements</a> - the template parameters of basic_json</li> <li><a href=../../features/serialization/ >Serialization</a> - the output side of the library</li> <li><a href=../../features/namespace/ ><code>nlohmann</code> Namespace</a> - how the library namespace is structured</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="October 28, 2026 19:24:49 UTC">October 28, 2026</span> </span> </aside> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <nav class="md-footer__inner md-grid" aria-label=Footer> <a href=../design_goals/ class="md-footer__link md-footer__link--prev" aria-label="Previous: Design goals"> <div class="md-footer__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 Line truncated
|
||||
@@ -171,7 +171,7 @@ Layout of one 16-byte node of a JSON view index. Each row is 32 bits wide, and t
|
||||
| 2-3 | `extra` | `uint16_t` | numbers: the number of integer digits (low byte) and fraction digits (high byte), 255 for more; objects: the number of their key hash index (1-based), or 0; otherwise 0 |
|
||||
| 4-7 | `off` | `uint32_t` | where the value starts: the first byte after a string's opening quote (or its position in the buffer of decoded strings), the first byte of a number or literal, the bracket of an array or object |
|
||||
| 8-11 | `len` | `uint32_t` | strings: the length after decoding; floats and literals: the length of the token; arrays and objects: the number of elements |
|
||||
| 12-15 | `next` | `uint32_t` | arrays and objects: the number of nodes of the subtree, including the node itself |
|
||||
| 12-15 | `next` | `uint32_t` | arrays and objects: the number of nodes of the subtree, including the node itself; strings with escapes: the position of the opening quote in the source plus one if the document was parsed with [`JSON_DIAGNOSTIC_POSITIONS`](https://json.nlohmann.me/api/macros/json_diagnostic_positions/index.md), or 0 if it was not; all other values: 0 |
|
||||
|
||||
Fields of a node, by their byte offset within the 16-byte node. Integers use bytes 8-15 differently, see below.
|
||||
|
||||
@@ -180,6 +180,7 @@ Fields of a node, by their byte offset within the 16-byte node. Integers use byt
|
||||
- **Object members** are the node of the key (a string) followed by the nodes of the value.
|
||||
- **Navigation** needs no pointers: the elements of an array or object follow its node, and the node after a value's subtree is `next` nodes further for an array or object, and the next node otherwise (`document_data::after`). Views step from element to element this way and skip whole subtrees in constant time.
|
||||
- **Offsets** are 32 bits wide, so a document is limited to 4294967279 bytes, 4 GiB minus 16 bytes (a margin below 2^32 for positions one scanner step past the end of the text; `out_of_range.416`).
|
||||
- **Source positions** ([`JSON_DIAGNOSTIC_POSITIONS`](https://json.nlohmann.me/api/macros/json_diagnostic_positions/index.md)) are derived by [`materialize()`](https://json.nlohmann.me/api/basic_json_view/materialize/index.md) and cost almost nothing while parsing: the only work is storing the offset of the opening quote of a string with escapes in its `next`, which is otherwise unused. A scalar's range follows from `off` and its length, a string with escapes is scanned from its opening quote (`next`) to the closing one, and the end of an array or object is found by scanning from the end of its last element over whitespace, comments, and a trailing comma. `materialize()` hands these positions to the SAX builder of `parse()` in place of its lexer.
|
||||
- **Large objects** (128 members or more) get a hash index for their keys after parsing ([`detail/view/object_index.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/object_index.hpp)): an open-addressing table whose slots hold the distance from the object's node to a key's node, so that a lookup does not compare every key. Of duplicate keys the table leads to the first, as a linear search does. The object's `extra` holds the number of its table. Only 65,535 tables fit into `extra`; objects beyond them are searched linearly.
|
||||
|
||||
For example, `{"a": [1, 2.5]}` becomes five nodes. Each node's elements follow it, and `next` leads from an array or object past its subtree:
|
||||
@@ -219,7 +220,7 @@ Editable documents ([`json_editable_document`](https://json.nlohmann.me/api/json
|
||||
- A value that an entry of such a sequence links to gets the flag *linked* (bit 5): its extent in the parsed layout (`next`) no longer matters, so a scalar can replace an array or object there in place.
|
||||
- Views of read-only documents compile without any of this: how views walk the index is a template parameter (`navigation<Editable>`).
|
||||
|
||||
Images ([`save`](https://json.nlohmann.me/api/basic_json_document/save/index.md) and [`load`](https://json.nlohmann.me/api/basic_json_document/load/index.md), [`detail/view/image.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/image.hpp)) store the nodes as they are: a 64-byte header (the magic bytes `NJVI`, a format version, the sizes, and reserved bytes that must be zero), the nodes, the text, and the decoded strings. An edited document is first written in document order, as the parser would have written it (without links), and the numbers of the hash indexes are cleared, since `load` rebuilds the indexes. So a change of the node layout is a change of the image format: it must raise `image_version`, and `load` then rejects images of other versions (`parse_error.116`) instead of misreading them.
|
||||
Images ([`save`](https://json.nlohmann.me/api/basic_json_document/save/index.md) and [`load`](https://json.nlohmann.me/api/basic_json_document/load/index.md), [`detail/view/image.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/image.hpp)) store the nodes as they are: a 64-byte header (the magic bytes `NJVI`, a format version, the sizes, and reserved bytes that must be zero), the nodes, the text, and the decoded strings. An edited document is first written in document order, as the parser would have written it (without links), and the numbers of the hash indexes are cleared, since `load` rebuilds the indexes. The flag *new* is kept, as these values have no position in the text. So a change of the node layout is a change of the image format: it must raise `image_version`, and `load` then rejects images of other versions (`parse_error.116`) instead of misreading them.
|
||||
|
||||
## Input adapters
|
||||
|
||||
|
||||
@@ -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=description content="JSON for Modern C++ is a header-only C++11 library that makes JSON a first-class data type."><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/releases/unreleased/" rel="canonical"><link href=../ rel=prev><link href=../v3.12.0/ rel=next><link rel=icon href=../../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.7.7"><title>Unreleased - JSON for Modern C++</title><link rel=stylesheet href=../../../assets/stylesheets/main.ec1eaa64.min.css><link rel=stylesheet href=../../../assets/stylesheets/palette.ab4e12ef.min.css><link rel=stylesheet href=../../../css/custom.css><link rel=stylesheet href=../../../css/brand.css><link rel=stylesheet href=../../../css/fig-sax.css><link rel=stylesheet href=../../../css/fig-jsonview.css><link rel=stylesheet href=../../../css/fig-exceptions.css><link rel=stylesheet href=../../../css/fig-pointer.css><link rel=stylesheet href=../../../css/fig-charts.css><link rel=stylesheet href=../../../css/fig-integration.css><link rel=stylesheet href=../../../css/fig-macros.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=custom data-md-color-accent=custom> <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=#unreleased 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> <img src=../../../images/wordmark-header.svg alt=logo> </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> Unreleased </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=custom data-md-color-accent=custom 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=custom data-md-color-accent=custom 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-.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=description content="JSON for Modern C++ is a header-only C++11 library that makes JSON a first-class data type."><meta name=author content="Niels Lohmann"><link href="https://json.nlohmann.me/home/releases/unreleased/" rel="canonical"><link href=../ rel=prev><link href=../v3.12.0/ rel=next><link rel=icon href=../../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.7.7"><title>Unreleased - JSON for Modern C++</title><link rel=stylesheet href=../../../assets/stylesheets/main.ec1eaa64.min.css><link rel=stylesheet href=../../../assets/stylesheets/palette.ab4e12ef.min.css><link rel=stylesheet href=../../../css/custom.css><link rel=stylesheet href=../../../css/brand.css><link rel=stylesheet href=../../../css/fig-sax.css><link rel=stylesheet href=../../../css/fig-jsonview.css><link rel=stylesheet href=../../../css/fig-exceptions.css><link rel=stylesheet href=../../../css/fig-pointer.css><link rel=stylesheet href=../../../css/fig-charts.css><link rel=stylesheet href=../../../css/fig-integration.css><link rel=stylesheet href=../../../css/fig-macros.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=custom data-md-color-accent=custom> <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=#unreleased 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> <img src=../../../images/wordmark-header.svg alt=logo> </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> Unreleased </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=custom data-md-color-accent=custom 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=custom data-md-color-accent=custom 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-.5Line truncated
|
||||
@@ -100,6 +100,7 @@ These changes are part of the `develop` branch, but not of a release yet.
|
||||
- [`basic_json::patch_inplace`](https://json.nlohmann.me/api/basic_json/patch_inplace/index.md): Added [`out_of_range.413`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range413) and stopped silently ignoring a "remove" operation whose target location has a non-object/non-array parent in version 3.13.0 unreleased.
|
||||
- [`basic_json::patch_inplace`](https://json.nlohmann.me/api/basic_json/patch_inplace/index.md): Added [`out_of_range.414`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range414) and rejected a "move" operation whose "from" location is a proper prefix of its "path" location instead of silently producing a corrupted result in version 3.13.0 unreleased.
|
||||
- [`basic_json::patch_inplace`](https://json.nlohmann.me/api/basic_json/patch_inplace/index.md): Throws [`parse_error.109`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error109) instead of [`out_of_range.404`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range404) for a one-character array index that is not a digit (e.g., `/x`) in version 3.13.0 unreleased, as it already did for longer ones.
|
||||
- [`basic_json::patch_inplace`](https://json.nlohmann.me/api/basic_json/patch_inplace/index.md): Applying a JSON value as patch to itself (or, with `JSON_DIAGNOSTICS`, to a value stored inside it) no longer results in undefined behavior in version 3.13.0 unreleased.
|
||||
- [`basic_json::sax_parse`](https://json.nlohmann.me/api/basic_json/sax_parse/index.md): Added `ignore_trailing_commas` in version 3.13.0 unreleased.
|
||||
- [`basic_json::sax_parse`](https://json.nlohmann.me/api/basic_json/sax_parse/index.md): Added `tag_handler` in version 3.13.0 unreleased.
|
||||
- [`basic_json::sax_parse`](https://json.nlohmann.me/api/basic_json/sax_parse/index.md): Extended container support (1) to include types with lvalue-only ADL `begin`/`end` (matching `std::begin`/`std::end` semantics) in version 3.13.0 unreleased.
|
||||
@@ -138,6 +139,7 @@ These changes are part of the `develop` branch, but not of a release yet.
|
||||
- [`basic_json::value`](https://json.nlohmann.me/api/basic_json/value/index.md): Overload 2: Support for keys convertible to `std::string_view` added in version 3.13.0 unreleased, consistently across the lookup functions.
|
||||
- [`basic_json::value`](https://json.nlohmann.me/api/basic_json/value/index.md): Overload 3: Extended to work with arrays in version 3.13.0 unreleased.
|
||||
- [`basic_json::value`](https://json.nlohmann.me/api/basic_json/value/index.md): Overload 3: Throws [`parse_error.109`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error109) instead of returning `default_value` for a one-character array index that is not a digit (e.g., `/x`) in version 3.13.0 unreleased, as it already did for longer ones.
|
||||
- [`json_pointer::operator/=`](https://json.nlohmann.me/api/json_pointer/operator_slasheq/index.md): Overload 1: Appending a JSON pointer to itself no longer results in undefined behavior in version 3.13.0 unreleased.
|
||||
- [`JSON_HAS_CPP_11, JSON_HAS_CPP_14, JSON_HAS_CPP_17, JSON_HAS_CPP_20, JSON_HAS_CPP_23, JSON_HAS_CPP_26`](https://json.nlohmann.me/api/macros/json_has_cpp_11/index.md): Added `JSON_HAS_CPP_26` in version 3.13.0 unreleased.
|
||||
- [`JSON_HAS_RANGES`](https://json.nlohmann.me/api/macros/json_has_ranges/index.md): Added the exclusions for libstdc++ < 11, Clang < 16 with libstdc++, libc++ < 16, and nvcc (CUDA) 12.0.x and 12.1.x in version 3.13.0 unreleased.
|
||||
- [`JSON_USE_IMPLICIT_CONVERSIONS`](https://json.nlohmann.me/api/macros/json_use_implicit_conversions/index.md): Also affects the conversion between `basic_json` specializations with different string types since version 3.13.0 unreleased.
|
||||
|
||||
Reference in new issue
Block a user