From aef2873abf813a8a4789e63f8f01a32f1e6b1505 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Oct 2026 16:30:38 +0200 Subject: [PATCH] Update the json_view banner and type_error.319 for editable documents The banner still described a read-only view, and the documentation of type_error.319 listed set and push_back only, although insert rejects binary values as well. Signed-off-by: Niels Lohmann --- docs/mkdocs/docs/home/exceptions.md | 5 +++-- include/nlohmann/json_view.hpp | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/mkdocs/docs/home/exceptions.md b/docs/mkdocs/docs/home/exceptions.md index 71f90e476..3f5ed1ea9 100644 --- a/docs/mkdocs/docs/home/exceptions.md +++ b/docs/mkdocs/docs/home/exceptions.md @@ -807,8 +807,9 @@ does not list an enumerator and it is therefore converted like the first listed ### json.exception.type_error.319 -[`basic_json_document::set`](../api/basic_json_document/set.md) and -[`basic_json_document::push_back`](../api/basic_json_document/push_back.md) can store any `basic_json` value except +[`basic_json_document::set`](../api/basic_json_document/set.md), +[`basic_json_document::push_back`](../api/basic_json_document/push_back.md), and +[`basic_json_document::insert`](../api/basic_json_document/insert.md) can store any `basic_json` value except a binary one: a `json_document` has no representation for [binary values](../features/binary_values.md), which only ever arise from parsing a binary format or from an explicit [`json::binary`](../api/basic_json/binary.md) value, not from JSON text. diff --git a/include/nlohmann/json_view.hpp b/include/nlohmann/json_view.hpp index a0c7f5ba4..72e7a4397 100644 --- a/include/nlohmann/json_view.hpp +++ b/include/nlohmann/json_view.hpp @@ -7,16 +7,18 @@ // SPDX-License-Identifier: MIT /****************************************************************************\ - * Zero-copy, read-only view of a parsed JSON text. * + * Zero-copy view of a parsed JSON text. * * * * json_document::parse() builds a flat index of the values of a JSON text * * (16 bytes per value) instead of a tree of basic_json values. Strings and * * numbers stay in the source text; only strings with escapes are decoded, * * into one buffer. json_view is a handle to one value of the document, with * * the read-only part of the basic_json interface; materialize() turns a * - * subtree into the basic_json value that parse() would produce. * + * subtree into the basic_json value that parse() would produce. An editable * + * document (json_editable_document) also has set(), push_back(), insert(), * + * and erase(): edits never write to the source text, and views stay valid. * * * - * The source text must outlive a document that borrows it (lvalue byte * + * The source text must outlive a document that borrows it (lvalue byte * * containers, C strings); rvalue strings, streams, and other inputs are * * owned by the document. * \****************************************************************************/