mirror of
https://github.com/nlohmann/json.git
synced 2026-03-04 00:06:28 +00:00
📝 add documentation
This commit is contained in:
@@ -230,6 +230,7 @@ Access to the JSON value
|
||||
- [**from_cbor**](from_cbor.md) (static) - create a JSON value from an input in CBOR format
|
||||
- [**from_msgpack**](from_msgpack.md) (static) - create a JSON value from an input in MessagePack format
|
||||
- [**from_ubjson**](from_ubjson.md) (static) - create a JSON value from an input in UBJSON format
|
||||
- [**to_bon8**](to_bon8.md) (static) - create a BON8 serialization of a given JSON value
|
||||
- [**to_bson**](to_bson.md) (static) - create a BSON serialization of a given JSON value
|
||||
- [**to_cbor**](to_cbor.md) (static) - create a CBOR serialization of a given JSON value
|
||||
- [**to_msgpack**](to_msgpack.md) (static) - create a MessagePack serialization of a given JSON value
|
||||
|
||||
@@ -25,7 +25,7 @@ ubjson
|
||||
: UBJSON (Universal Binary JSON)
|
||||
|
||||
bson
|
||||
: BSON (Binary JSON)
|
||||
: BSON (Binary JSON)
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
57
doc/mkdocs/docs/api/basic_json/to_bon8.md
Normal file
57
doc/mkdocs/docs/api/basic_json/to_bon8.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# basic_json::to_bon8
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
static std::vector<std::uint8_t> to_bon8(const basic_json& j);
|
||||
|
||||
// (2)
|
||||
static void to_bon8(const basic_json& j, detail::output_adapter<std::uint8_t> o);
|
||||
static void to_bon8(const basic_json& j, detail::output_adapter<char> o);
|
||||
```
|
||||
|
||||
Serializes a given JSON value `j` to a byte vector using the BON8 serialization format. BON8 is a binary serialization
|
||||
format which aims to be more compact than JSON itself, yet more efficient to parse.
|
||||
|
||||
1. Returns a byte vector containing the BON8 serialization.
|
||||
2. Writes the BON8 serialization to an output adapter.
|
||||
|
||||
## Parameters
|
||||
|
||||
`j` (in)
|
||||
: JSON value to serialize
|
||||
|
||||
`o` (in)
|
||||
: output adapter to write serialization to
|
||||
|
||||
## Return value
|
||||
|
||||
1. BON8 serialization as byte vector
|
||||
2. /
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the JSON value `j`.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the serialization of a JSON value to a byte vector in BON8 format.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/to_bon8.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/to_bon8.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.11.0.
|
||||
Reference in New Issue
Block a user