| 128 | } |
| 129 | |
| 130 | void decode_cbor_byte_string() |
| 131 | { |
| 132 | // byte string of length 5 |
| 133 | std::vector<uint8_t> buf = {0x45,'H','e','l','l','o'}; |
| 134 | json j = cbor::decode_cbor<json>(buf); |
| 135 | |
| 136 | auto bytes = j.as<byte_string>(); |
| 137 | |
| 138 | // byte_string to ostream displays as hex |
| 139 | std::cout << "(1) "<< bytes << "\n\n"; |
| 140 | |
| 141 | // byte string value to JSON text becomes base64url |
| 142 | std::cout << "(2) " << j << '\n'; |
| 143 | } |
| 144 | |
| 145 | void decode_byte_string_with_encoding_hint() |
| 146 | { |