1#include <iostream> 2#include <iomanip> 3#include <nlohmann/json.hpp> 4 5using json = nlohmann::json; 6using namespace nlohmann::literals; 7 8int main() 9{ 10 // create a JSON value 11 json j = R"({"compact": true, "schema": 0})"_json; 12 13 // serialize it to MessagePack 14 std::vector<std::uint8_t> v = json::to_msgpack(j); 15 16 // print the vector content 17 for (auto& byte : v) 18 { 19 std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " "; 20 } 21 std::cout << std::endl; 22} 23