mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
💡 update documentation
This commit is contained in:
@ -55,6 +55,8 @@ binary | *size*: 256..65535 | byte string (2 by
|
||||
binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A
|
||||
binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B
|
||||
|
||||
Binary values with subtype are mapped to tagged values (0xD8..0xDB) depending on the subtype, followed by a byte string,
|
||||
see "binary" cells in the table above.
|
||||
|
||||
!!! success "Complete mapping"
|
||||
|
||||
@ -162,7 +164,7 @@ Double-Precision Float | number_float | 0xFB
|
||||
|
||||
!!! warning "Tagged items"
|
||||
|
||||
Tagged items will throw a parse error by default. However, they can be ignored by passing `cbor_tag_handler_t::ignore` to function `from_cbor`.
|
||||
Tagged items will throw a parse error by default. They can be ignored by passing `cbor_tag_handler_t::ignore` to function `from_cbor`. They can be stored by passing `cbor_tag_handler_t::store` to function `from_cbor`.
|
||||
|
||||
??? example
|
||||
|
||||
|
@ -25,7 +25,7 @@ to efficiently encode JSON values to byte vectors and to decode such vectors.
|
||||
| Format | Binary values | Binary subtypes |
|
||||
| ----------- | ------------- | --------------- |
|
||||
| BSON | supported | supported |
|
||||
| CBOR | supported | not supported |
|
||||
| CBOR | supported | supported |
|
||||
| MessagePack | supported | supported |
|
||||
| UBJSON | not supported | not supported |
|
||||
|
||||
|
@ -9,10 +9,10 @@ JSON itself does not have a binary value. As such, binary values are an extensio
|
||||
```plantuml
|
||||
class json::binary_t {
|
||||
-- setters --
|
||||
+void set_subtype(std::uint8_t subtype)
|
||||
+void set_subtype(std::uint64_t subtype)
|
||||
+void clear_subtype()
|
||||
-- getters --
|
||||
+std::uint8_t subtype() const
|
||||
+std::uint64_t subtype() const
|
||||
+bool has_subtype() const
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ j.get_binary().has_subtype(); // returns true
|
||||
j.get_binary().size(); // returns 4
|
||||
```
|
||||
|
||||
For convencience, binary JSON values can be constructed via `json::binary`:
|
||||
For convenience, binary JSON values can be constructed via `json::binary`:
|
||||
|
||||
```cpp
|
||||
auto j2 = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 23);
|
||||
@ -76,6 +76,7 @@ auto j3 = json::binary({0xCA, 0xFE, 0xBA, 0xBE});
|
||||
|
||||
j2 == j; // returns true
|
||||
j3.get_binary().has_subtype(); // returns false
|
||||
j3.get_binary().subtype(); // returns std::uint64_t(-1) as j3 has no subtype
|
||||
```
|
||||
|
||||
|
||||
@ -184,7 +185,7 @@ JSON does not have a binary type, and this library does not introduce a new type
|
||||
0xCA 0xFE 0xBA 0xBE // content
|
||||
```
|
||||
|
||||
Note that the subtype is serialized as tag. However, parsing tagged values yield a parse error unless `json::cbor_tag_handler_t::ignore` is passed to `json::from_cbor`.
|
||||
Note that the subtype is serialized as tag. However, parsing tagged values yield a parse error unless `json::cbor_tag_handler_t::ignore` or `json::cbor_tag_handler_t::store` is passed to `json::from_cbor`.
|
||||
|
||||
```json
|
||||
{
|
||||
|
Reference in New Issue
Block a user