mirror of
https://github.com/nlohmann/json.git
synced 2026-10-03 22:06:59 +01:00
deploy: 63c10a51fc
This commit is contained in:
@@ -55,7 +55,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
||||
## Exceptions
|
||||
|
||||
- Throws [`other_error.502`](../../home/exceptions.md#jsonexceptionother_error502) if `use_type` is true and `use_size`
|
||||
is false.
|
||||
is false, and `j` contains a non-empty array, object, or binary value.
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -63,7 +63,7 @@ Linear in the size of the JSON value `j`.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
??? example "Example: serialize a JSON value to BJData"
|
||||
|
||||
The example shows the serialization of a JSON value to a byte vector in BJData format.
|
||||
|
||||
@@ -77,6 +77,21 @@ Linear in the size of the JSON value `j`.
|
||||
--8<-- "examples/to_bjdata.output"
|
||||
```
|
||||
|
||||
??? example "Example: other_error.502 exception"
|
||||
|
||||
The example shows how requesting type annotations (`use_type`) without size annotations (`use_size`) throws an
|
||||
exception, because type-optimized containers can only be read back with a preceding size.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/to_bjdata__exception.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/to_bjdata__exception.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
||||
|
||||
Reference in New Issue
Block a user