docs: correct the json_view dump() guarantee for loaded images (#6087)

dump() said a view never throws type_error.316 because the text is always
validated. A document loaded with image_check::bounds or none can hold
invalid UTF-8: dump() writes it unchanged, and dump(ensure_ascii) throws
type_error.316. (The matching correction of number_token() is part of the
read() documentation change below which this commit is stacked.)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann authored and GitHub committed 2026-11-11 22:36:17 +01:00
1 parent 94331d1050
commit 53d097f980
1 file changed
+5 -2
+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