From 53d097f98076370b2369ab32b6a1ff8d36097da7 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 11 Nov 2026 22:36:17 +0100 Subject: [PATCH] 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 --- docs/mkdocs/docs/api/basic_json_view/dump.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/mkdocs/docs/api/basic_json_view/dump.md b/docs/mkdocs/docs/api/basic_json_view/dump.md index 2fd64a2ce..112716852 100644 --- a/docs/mkdocs/docs/api/basic_json_view/dump.md +++ b/docs/mkdocs/docs/api/basic_json_view/dump.md @@ -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