📝 add documentation

This commit is contained in:
Niels Lohmann
2021-09-11 14:59:21 +02:00
parent 5221115ff1
commit 7c55a91004
10 changed files with 192 additions and 2 deletions
+1
View File
@@ -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 (Bin­ary JSON)
: BSON (Binary JSON)
## Version history
+57
View 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.
@@ -1,6 +1,6 @@
# BSON
BSON, short for Bin­ary JSON, is a bin­ary-en­coded seri­al­iz­a­tion of JSON-like doc­u­ments. Like JSON, BSON sup­ports the em­bed­ding of doc­u­ments and ar­rays with­in oth­er doc­u­ments and ar­rays. BSON also con­tains ex­ten­sions that al­low rep­res­ent­a­tion of data types that are not part of the JSON spec. For ex­ample, BSON has a Date type and a BinData type.
BSON, short for Binary JSON, is a binary-encoded serialization of JSON-like documents. Like JSON, BSON supports the embedding of documents and arrays within other documents and arrays. BSON also contains extensions that allow representation of data types that are not part of the JSON spec. For example, BSON has a Date type and a BinData type.
!!! abstract "References"
@@ -6,6 +6,7 @@ Though JSON is a ubiquitous data format, it is not a very compact format suitabl
- [CBOR](cbor.md) (Concise Binary Object Representation),
- [MessagePack](messagepack.md), and
- [UBJSON](ubjson.md) (Universal Binary JSON)
- BON8
to efficiently encode JSON values to byte vectors and to decode such vectors.
@@ -19,6 +20,7 @@ to efficiently encode JSON values to byte vectors and to decode such vectors.
| CBOR | complete | incomplete, but all JSON types are supported |
| MessagePack | complete | complete |
| UBJSON | complete | complete |
| BON8 | complete | not yet implemented |
### Binary values
@@ -28,6 +30,7 @@ to efficiently encode JSON values to byte vectors and to decode such vectors.
| CBOR | supported | supported |
| MessagePack | supported | supported |
| UBJSON | not supported | not supported |
| BON8 | not supported | not supported |
See [binary values](../binary_values.md) for more information.