This commit is contained in:
nlohmann committed 2026-11-01 16:56:42 +00:00
1 parent cf84df303b
commit 264aee6773
39 files changed
+586 -498

No files matched your search

+1 -1
View File
@@ -43,7 +43,7 @@ Strong guarantee: there are no changes to the view or the document it refers to.
1. Throws [`type_error.306`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error306) if the value is not an object — the same exception, with the same message, that [`BasicJsonType::value`](https://json.nlohmann.me/api/basic_json/value/index.md) throws for the same call. If a member with key `key` is found, throws whatever converting it to `T` throws (typically [`type_error.302`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error302), with the same message [`BasicJsonType::value`](https://json.nlohmann.me/api/basic_json/value/index.md) throws for the same mismatch); a missing member never throws.
1. Throws [`type_error.306`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error306) if this value — not the value `ptr` resolves to — is neither an object nor an array. Throws [`parse_error.106`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error106) or [`parse_error.109`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error109) if `ptr` contains a malformed array index. If `ptr` resolves to a value, throws whatever converting it to `T` throws. Every other way `ptr` can fail to resolve — a missing key, an out-of-range or "`-`" array index, an unresolvable token on a primitive — yields `default_value` instead of throwing, exactly as [`BasicJsonType::value`](https://json.nlohmann.me/api/basic_json/value/index.md) catches `out_of_range` and returns `default_value`.
None of these exceptions carry a [`JSON_DIAGNOSTICS`](https://json.nlohmann.me/api/macros/json_diagnostics/index.md) path: the view has no `BasicJsonType` value to point at, so the exception is created without one, even if `BasicJsonType` was built with `JSON_DIAGNOSTICS` enabled.
As for `BasicJsonType`, with [`JSON_DIAGNOSTICS`](https://json.nlohmann.me/api/macros/json_diagnostics/index.md) these exceptions name the JSON Pointer path of the value within the document, and with [`JSON_DIAGNOSTIC_POSITIONS`](https://json.nlohmann.me/api/macros/json_diagnostic_positions/index.md) its bytes in the source text (when [`materialize()`](https://json.nlohmann.me/api/basic_json_view/materialize/index.md) sets them).
## Complexity