• Home
  • Raw
  • Download

Lines Matching full:binary

1 # Binary Values
3 …mplements several [binary formats](binary_formats/index.md) that encode JSON in an efficient way. …
5binary value. As such, binary values are an extension that this library implements to store values…
7 ## API for binary values
22binary values are stored as `std::vector<std::uint8_t>`. This type can be changed by providing a t…
25 auto binary = json::binary_t({0xCA, 0xFE, 0xBA, 0xBE});
32 binary.has_subtype(); // returns false
39 binary.set_subtype(23);
41 binary.subtype(); // returns 23
47 binary.size(); // returns 4
48 binary[1]; // returns 0xFE
54 json j = binary;
57 Binary values are primitive values just like numbers or strings:
64 Given a binary JSON value, the `binary_t` can be accessed by reference as via `get_binary()`:
71 For convencience, binary JSON values can be constructed via `json::binary`:
74 auto j2 = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 23);
75 auto j3 = json::binary({0xCA, 0xFE, 0xBA, 0xBE});
85 Binary values are serialized differently according to the formats.
89 JSON does not have a binary type, and this library does not introduce a new type as this would brea…
96 // create a binary value of subtype 42
98 j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42);
108 "binary": {
115 !!! warning "No roundtrip for binary values"
117 …he objects generated by binary values back to binary values. This is by design to remain standards…
121 …ports binary values and subtypes. If a subtype is given, it is used and added as unsigned 8-bit in…
128 // create a binary value of subtype 42
130 j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42);
140 0x05 // binary value
141 0x62 0x69 0x6E 0x61 0x72 0x79 0x00 // key "binary" + null byte
152 "binary": {
161 …OR](binary_formats/cbor.md) supports binary values, but no subtypes. Subtypes will be serialized a…
168 // create a binary value of subtype 42
170 j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42);
181 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary"
191 "binary": {
200 [MessagePack](binary_formats/messagepack.md) supports binary values and subtypes. If a subtype is g…
209 // create a binary value of subtype 42
211 j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42);
222 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary"
232 "binary": {
241 …N](binary_formats/ubjson.md) neither supports binary values nor subtypes, and proposes to serializ…
248 // create a binary value of subtype 42 (will be ignored in UBJSON)
250 j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42);
261 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary"
283 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary"
289 …Note that subtype (42) is **not** serialized and that UBJSON has **no binary type**, and deseriali…
293 "binary": [202, 254, 186, 190]