| 10 | using namespace jsoncons; |
| 11 | |
| 12 | void data_model_example1() |
| 13 | { |
| 14 | json j(json_array_arg); |
| 15 | |
| 16 | j.emplace_back("foo"); |
| 17 | std::vector<uint8_t> bstr = {'b','a','r'}; |
| 18 | j.emplace_back(byte_string_arg, bstr); |
| 19 | j.emplace_back("-18446744073709551617", semantic_tag::bigint); |
| 20 | j.emplace_back("273.15", semantic_tag::bigdec); |
| 21 | j.emplace_back("2018-10-19 12:41:07-07:00", semantic_tag::datetime); |
| 22 | j.emplace_back(1431027667, semantic_tag::epoch_second); |
| 23 | j.emplace_back(-1431027667, semantic_tag::epoch_second); |
| 24 | j.emplace_back(1431027667.5, semantic_tag::epoch_second); |
| 25 | |
| 26 | std::cout << "(1)\n" << pretty_print(j) << "\n\n"; |
| 27 | |
| 28 | std::vector<uint8_t> bytes; |
| 29 | cbor::encode_cbor(j, bytes); |
| 30 | std::cout << "(2)\n" << byte_string_view(bytes) << "\n\n"; |
| 31 | /* |
| 32 | 88 -- Array of length 8 |
| 33 | 63 -- String value of length 3 |
| 34 | 666f6f -- "foo" |
| 35 | 43 -- Byte string value of length 3 |
| 36 | 626172 -- 'b''a''r' |
| 37 | c3 -- Tag 3 (negative bignum) |
| 38 | 49 Byte string value of length 9 |
| 39 | 010000000000000000 -- Bytes content |
| 40 | c4 - Tag 4 (decimal fraction) |
| 41 | 82 -- Array of length 2 |
| 42 | 21 -- -2 |
| 43 | 19 6ab3 -- 27315 |
| 44 | c0 -- Tag 0 (date-time) |
| 45 | 78 19 -- Length (25) |
| 46 | 323031382d31302d31392031323a34313a30372d30373a3030 -- "2018-10-19 12:41:07-07:00" |
| 47 | c1 -- Tag 1 (epoch time) |
| 48 | 1a -- uint32_t |
| 49 | 554bbfd3 -- 1431027667 |
| 50 | c1 |
| 51 | 3a |
| 52 | 554bbfd2 |
| 53 | c1 |
| 54 | fb |
| 55 | 41d552eff4e00000 |
| 56 | */ |
| 57 | } |
| 58 | |
| 59 | void data_model_example2() |
| 60 | { |
no test coverage detected