mirror of
https://github.com/nlohmann/json.git
synced 2026-10-03 13:10:33 +00:00
deploy: 63c10a51fc
This commit is contained in:
@@ -48,16 +48,16 @@ represent a byte array in modern C++.
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
### Default type
|
||||
|
||||
The default values for `BinaryType` is `#!cpp std::vector<std::uint8_t>`.
|
||||
|
||||
#### Supported byte types
|
||||
### Supported byte types
|
||||
|
||||
`#!cpp std::vector<std::uint8_t>`, `#!cpp std::vector<char>`, and `#!cpp std::vector<std::byte>` are supported.
|
||||
Regardless of which of them is configured, [`dump`](dump.md) writes the bytes as the numbers 0..255.
|
||||
|
||||
#### Custom BinaryType behavior
|
||||
### Custom BinaryType behavior
|
||||
|
||||
When a custom `BinaryType` is configured (other than the default `#!cpp std::vector<std::uint8_t>`), you can assign
|
||||
values of that type directly to a `basic_json` instance, and they will automatically be recognized as binary values
|
||||
@@ -89,12 +89,12 @@ assert(extracted == data);
|
||||
This automatic type detection is a convenience feature that only applies to custom (non-default) `BinaryType` configurations.
|
||||
The default `nlohmann::json` continues to treat `#!cpp std::vector<std::uint8_t>` as arrays for backward compatibility.
|
||||
|
||||
#### Storage
|
||||
### Storage
|
||||
|
||||
Binary Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of the
|
||||
type `#!cpp binary_t*` must be dereferenced.
|
||||
|
||||
#### Notes on subtypes
|
||||
### Notes on subtypes
|
||||
|
||||
- CBOR
|
||||
- Binary values are represented as byte strings. Subtypes are written as tags.
|
||||
|
||||
Reference in New Issue
Block a user