]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
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 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 | } |