]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/examples/to_bson.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / nlohmann-json / doc / examples / to_bson.cpp
1 #include <iostream>
2 #include <iomanip>
3 #include <nlohmann/json.hpp>
4
5 using json = nlohmann::json;
6
7 int main()
8 {
9 // create a JSON value
10 json j = R"({"compact": true, "schema": 0})"_json;
11
12 // serialize it to BSON
13 std::vector<std::uint8_t> v = json::to_bson(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 }