| 88 | } |
| 89 | |
| 90 | void ext_example() |
| 91 | { |
| 92 | std::vector<uint8_t> input = { |
| 93 | |
| 94 | 0x82, // map, length 2 |
| 95 | 0xa5, // string, length 5 |
| 96 | 'H','e','l','l','o', |
| 97 | 0xa5, // string, length 5 |
| 98 | 'W','o','r','l','d', |
| 99 | 0xa4, // string, length 4 |
| 100 | 'D','a','t','a', |
| 101 | 0xc7, // ext8 format code |
| 102 | 0x06, // length 6 |
| 103 | 0x07, // type |
| 104 | 'f','o','o','b','a','r' |
| 105 | }; |
| 106 | |
| 107 | ojson j = msgpack::decode_msgpack<ojson>(input); |
| 108 | |
| 109 | std::cout << "(1)\n" << pretty_print(j) << "\n\n"; |
| 110 | std::cout << "(2) " << j["Data"].tag() << "(" << j["Data"].ext_tag() << ")\n\n"; |
| 111 | |
| 112 | // Get ext value as a std::vector<uint8_t> |
| 113 | auto v = j["Data"].as<std::vector<uint8_t>>(); |
| 114 | |
| 115 | std::cout << "(3)\n"; |
| 116 | std::cout << jsoncons::byte_string_view(v) << "\n\n"; |
| 117 | |
| 118 | std::vector<uint8_t> output; |
| 119 | msgpack::encode_msgpack(j,output); |
| 120 | assert(output == input); |
| 121 | } |
| 122 | |
| 123 | void duration_example1() |
| 124 | { |
no test coverage detected