MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / example1

Function example1

examples/src/msgpack_examples.cpp:15–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace msgpack = jsoncons::msgpack;
14
15void example1()
16{
17ojson j1 = ojson::parse(R"(
18[
19 { "category": "reference",
20 "author": "Nigel Rees",
21 "title": "Sayings of the Century",
22 "price": 8.95
23 },
24 { "category": "fiction",
25 "author": "Evelyn Waugh",
26 "title": "Sword of Honour",
27 "price": 12.99
28 }
29]
30)");
31
32 std::vector<uint8_t> v;
33 msgpack::encode_msgpack(j1, v);
34
35 ojson j2 = msgpack::decode_msgpack<ojson>(v);
36
37 std::cout << pretty_print(j2) << '\n';
38
39 json j3 = msgpack::decode_msgpack<json>(v);
40
41 std::cout << pretty_print(j3) << '\n';
42
43 std::cout << '\n';
44
45 //wjson j4 = msgpack::decode_msgpack<wjson>(v);
46
47 //std::wcout << pretty_print(j4) << '\n';
48
49 //std::cout << '\n';
50}
51
52void example2()
53{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
encode_msgpackFunction · 0.85
pretty_printFunction · 0.85

Tested by

no test coverage detected