This commit is contained in:
nlohmann
2026-11-12 11:46:38 +00:00
parent 8ddeea7128
commit 5097c20962
516 changed files with 7306 additions and 5984 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5 -2
View File
@@ -48,8 +48,11 @@ Strong exception safety: if an exception is thrown, there are no changes to the
May throw `#!cpp std::bad_alloc` if allocating the output string fails. Unlike
[`BasicJsonType::dump`](../basic_json/dump.md), there is no `error_handler` parameter and no
[`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316): the view only ever holds text the parser
already validated as UTF-8, so there is nothing to replace or ignore.
[`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316): the parser validated the text the view
holds as UTF-8, so there is nothing to replace or ignore. Only a document loaded with
[`image_check::bounds` or `image_check::none`](../basic_json_document/load.md#image_check) can still throw it: these do
not check the strings, so `dump()` writes such a string as it is, which can be invalid UTF-8 or invalid JSON, and
`dump()` with `ensure_ascii` set to `#!cpp true` throws `type_error.316` for invalid UTF-8.
## Complexity
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -29,7 +29,7 @@ Strong exception safety: if an exception is thrown, there are no changes to the
## Exceptions
May throw `std::bad_alloc` if allocating the output string fails. Unlike [`BasicJsonType::dump`](https://json.nlohmann.me/api/basic_json/dump/index.md), there is no `error_handler` parameter and no [`type_error.316`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error316): the view only ever holds text the parser already validated as UTF-8, so there is nothing to replace or ignore.
May throw `std::bad_alloc` if allocating the output string fails. Unlike [`BasicJsonType::dump`](https://json.nlohmann.me/api/basic_json/dump/index.md), there is no `error_handler` parameter and no [`type_error.316`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error316): the parser validated the text the view holds as UTF-8, so there is nothing to replace or ignore. Only a document loaded with [`image_check::bounds` or `image_check::none`](https://json.nlohmann.me/api/basic_json_document/load/#image_check) can still throw it: these do not check the strings, so `dump()` writes such a string as it is, which can be invalid UTF-8 or invalid JSON, and `dump()` with `ensure_ascii` set to `true` throws `type_error.316` for invalid UTF-8.
## Complexity
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
View File
@@ -46,6 +46,10 @@ The returned [`string_view_t`](index.md#member-types) is valid exactly as long a
source text, which for a borrowed document must remain valid **and unmodified** for as long as the document exists,
since floating-point values and unescaped strings are read from the source lazily.
A string with escapes, a string of a document that owns its text, and an edited string must not be passed to
[`read()`](../basic_json_document/read.md) of the document it came from: `read()` releases them before it parses its
input. Copy the string first. (A string read unchanged from a borrowed text is not affected.)
## Examples
??? example
File diff suppressed because one or more lines are too long
+2
View File
@@ -32,6 +32,8 @@ Constant.
The returned [`string_view_t`](https://json.nlohmann.me/api/basic_json_view/#member-types) is valid exactly as long as the view that produced it — see the [validity rules](https://json.nlohmann.me/api/basic_json_view/index.md) of `basic_json_view` — and, for a string with no escapes, for as long as the document's source text, which for a borrowed document must remain valid **and unmodified** for as long as the document exists, since floating-point values and unescaped strings are read from the source lazily.
A string with escapes, a string of a document that owns its text, and an edited string must not be passed to [`read()`](https://json.nlohmann.me/api/basic_json_document/read/index.md) of the document it came from: `read()` releases them before it parses its input. Copy the string first. (A string read unchanged from a borrowed text is not affected.)
## Examples
Example
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8 -3
View File
@@ -38,9 +38,14 @@ by the grammar; trailing zeros in the fraction; the case and sign of the exponen
useful precisely where that form must survive — a price or an identifier that must be reproduced exactly, or a
number too large for any of `BasicJsonType`'s number types to hold without loss.
The returned [`string_view_t`](index.md#member-types) always points into the document's
[`source()`](../basic_json_document/source.md) text — numbers are never decoded into the document's separate string
buffer — and is valid exactly as long as that text is, see the [validity rules](index.md) of `basic_json_view`.
The returned [`string_view_t`](index.md#member-types) points into the document's
[`source()`](../basic_json_document/source.md) text or, for a number written by an
[edit](../basic_json_document/index.md#edits), into storage owned by the document (the token of an edited `NaN` is
`nan`). It is valid exactly as long as that text or storage is, see the [validity rules](index.md) of
`basic_json_view`. Numbers are never decoded into the document's separate string buffer.
For the same reason, the token must not be passed to [`read()`](../basic_json_document/read.md) of the document it came
from if that document owns its text or the number was written by an edit: `read()` releases both before it parses.
## Examples
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -28,7 +28,9 @@ Constant.
`BasicJsonType` has no counterpart to this function: once a number is parsed into `number_integer_t`, `number_unsigned_t`, or `number_float_t`, its original textual form (leading zeros aside, which are already rejected by the grammar; trailing zeros in the fraction; the case and sign of the exponent; ...) is gone. `number_token()` is useful precisely where that form must survive — a price or an identifier that must be reproduced exactly, or a number too large for any of `BasicJsonType`'s number types to hold without loss.
The returned [`string_view_t`](https://json.nlohmann.me/api/basic_json_view/#member-types) always points into the document's [`source()`](https://json.nlohmann.me/api/basic_json_document/source/index.md) text — numbers are never decoded into the document's separate string buffer — and is valid exactly as long as that text is, see the [validity rules](https://json.nlohmann.me/api/basic_json_view/index.md) of `basic_json_view`.
The returned [`string_view_t`](https://json.nlohmann.me/api/basic_json_view/#member-types) points into the document's [`source()`](https://json.nlohmann.me/api/basic_json_document/source/index.md) text or, for a number written by an [edit](https://json.nlohmann.me/api/basic_json_document/#edits), into storage owned by the document (the token of an edited `NaN` is `nan`). It is valid exactly as long as that text or storage is, see the [validity rules](https://json.nlohmann.me/api/basic_json_view/index.md) of `basic_json_view`. Numbers are never decoded into the document's separate string buffer.
For the same reason, the token must not be passed to [`read()`](https://json.nlohmann.me/api/basic_json_document/read/index.md) of the document it came from if that document owns its text or the number was written by an edit: `read()` releases both before it parses.
## Examples
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -57,7 +57,9 @@ compared. Two arrays of different [`size()`](size.md) are rejected without visit
Only a single number, boolean, or `#!cpp null` value is ever materialized into a `BasicJsonType`, to reuse its
`operator==` — for numbers, so that values written differently in the source text but equal in value (e.g. an
integer and a floating-point literal) still compare equal, following the same rules `BasicJsonType` does for special
values such as `#!cpp NaN`. Constructing one of these scalars never allocates. Strings are compared directly, without
values such as `#!cpp NaN`: a `#!cpp NaN` that an [edit](../basic_json_document/set.md) wrote is not equal to itself, so
a view of it is not equal to itself either, nor is a view of an array or object that contains one, as for
`BasicJsonType`. Constructing one of these scalars never allocates. Strings are compared directly, without
allocating, either from the source text on both sides or, for overload 2, against `BasicJsonType`'s own string.
Arrays and objects are never materialized at all; only their elements or members are visited, one pair at a time.
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -38,7 +38,7 @@ Linear in the size of the compared values: every number, string, array element,
## Notes
Only a single number, boolean, or `null` value is ever materialized into a `BasicJsonType`, to reuse its `operator==` — for numbers, so that values written differently in the source text but equal in value (e.g. an integer and a floating-point literal) still compare equal, following the same rules `BasicJsonType` does for special values such as `NaN`. Constructing one of these scalars never allocates. Strings are compared directly, without allocating, either from the source text on both sides or, for overload 2, against `BasicJsonType`'s own string. Arrays and objects are never materialized at all; only their elements or members are visited, one pair at a time.
Only a single number, boolean, or `null` value is ever materialized into a `BasicJsonType`, to reuse its `operator==` — for numbers, so that values written differently in the source text but equal in value (e.g. an integer and a floating-point literal) still compare equal, following the same rules `BasicJsonType` does for special values such as `NaN`: a `NaN` that an [edit](https://json.nlohmann.me/api/basic_json_document/set/index.md) wrote is not equal to itself, so a view of it is not equal to itself either, nor is a view of an array or object that contains one, as for `BasicJsonType`. Constructing one of these scalars never allocates. Strings are compared directly, without allocating, either from the source text on both sides or, for overload 2, against `BasicJsonType`'s own string. Arrays and objects are never materialized at all; only their elements or members are visited, one pair at a time.
How objects are compared
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long