docs: integers are converted while parsing a document

Also say "They accept every input" in basic_json_document::parse.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-24 07:14:37 +02:00
1 parent e19efec1d3
commit 12fcf8ff8c
3 files changed
+6 -6

No files matched your search

@@ -9,8 +9,8 @@ class basic_json_document;
A parsed JSON text, held as a flat index of its values
([16 bytes per value](../../home/architecture.md#node-index-of-json-views)) instead of a tree of `BasicJsonType` values.
Strings and numbers stay in the source text; only strings that contain escapes are decoded, into one buffer owned by
the document. [`basic_json_view`](../basic_json_view/index.md) is a read-only handle to one value of a
Strings and floating-point numbers stay in the source text; integers are converted while parsing, and strings that
contain escapes are decoded into one buffer owned by the document. [`basic_json_view`](../basic_json_view/index.md) is a read-only handle to one value of a
`basic_json_document`; [`materialize()`](../basic_json_view/materialize.md) turns a subtree into the
`BasicJsonType` value that [`BasicJsonType::parse()`](../basic_json/parse.md) would have produced for it.
@@ -21,7 +21,7 @@ static basic_json_document parse(IteratorType first, IteratorType last,
Both overloads accept the same JSON text as [`BasicJsonType::parse()`](../basic_json/parse.md), with the same
`ignore_comments`/`ignore_trailing_commas` options, but build a [`basic_json_document`](index.md) (a flat index into
the input) instead of a tree of `BasicJsonType` values. They take every input `BasicJsonType::parse()` takes, and in
the input) instead of a tree of `BasicJsonType` values. They accept every input `BasicJsonType::parse()` takes, and in
addition a pointer to a null-terminated wide string (which `BasicJsonType::parse()` rejects). Contiguous inputs of
single-byte characters that stay alive can be borrowed; all others (streams, `#!cpp FILE*`, wide characters, which
must be converted to UTF-8, and non-contiguous iterators) are read into a copy that the document owns -- see the
+3 -3
View File
@@ -110,9 +110,9 @@ You can influence a DOM parse without switching to the SAX interface by passing
A third model sits between DOM and SAX: [`basic_json_document::parse`](../../api/basic_json_document/parse.md) parses
the input into a document that keeps the text and a flat index of the values in it, and
[`basic_json_view`](../../api/basic_json_view/index.md) gives read-only access to the values through that index.
The whole input is validated during parsing, but only strings that contain escape sequences are decoded right away
(into a buffer owned by the document). Numbers and all other strings stay in the source text and are only converted
when they are read, which is faster and uses less memory than building a tree of `basic_json` values when only parts
The whole input is validated during parsing, but only integers and strings that contain escape sequences are converted
right away (the strings into a buffer owned by the document). Floating-point numbers and all other strings stay in the
source text and are only converted when they are read, which is faster and uses less memory than building a tree of `basic_json` values when only parts
of the document are needed. A document can also be
modified in place, and it can be saved and loaded again without parsing it.