]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/examples/to_msgpack.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / nlohmann-json / doc / examples / to_msgpack.cpp
CommitLineData
1e59de90
TL
1#include <iostream>
2#include <iomanip>
3#include <nlohmann/json.hpp>
4
5using json = nlohmann::json;
6
7int main()
8{
9 // create a JSON value
10 json j = R"({"compact": true, "schema": 0})"_json;
11
12 // serialize it to MessagePack
13 std::vector<std::uint8_t> v = json::to_msgpack(j);
14
15 // print the vector content
16 for (auto& byte : v)
17 {
18 std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
19 }
20 std::cout << std::endl;
21}