1 #include <iostream> 2 #include <iomanip> 3 #include <nlohmann/json.hpp> 4 5 using json = nlohmann::json; 6 main()7int main() 8 { 9 // create a JSON value 10 json j = R"({"compact": true, "schema": 0})"_json; 11 12 // serialize it to CBOR 13 std::vector<uint8_t> v = json::to_cbor(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 } 22