This commit is contained in:
nlohmann
2026-09-26 02:05:51 +00:00
parent 90bef9173a
commit 82dd0b5615
287 changed files with 749 additions and 549 deletions
File diff suppressed because one or more lines are too long
+4
View File
@@ -118,6 +118,10 @@ The BSON reader is lenient in a few areas where the BSON specification is more r
If BSON input must be validated for strict specification compliance, validate it separately before passing it to `from_bson()`.
UTF-8 validation of string values
The BSON specification requires `string` values (type `0x02`) to be valid UTF-8. This library validates the bytes of every such string at decode time and rejects ill-formed UTF-8 with a [`parse_error.113`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error113) exception (or, with `allow_exceptions` set to `false`, a discarded value), rather than only failing later when the resulting value is dumped. Element (key) names and `binary` values (type `0x05`) are unaffected and are never validated, since they are read byte-by-byte as a C string, or are not required to hold text, respectively.
Example
```