2017-07-09 11:51:38 +02:00
|
|
|
#include <iostream>
|
2018-08-16 21:53:47 +02:00
|
|
|
#include <iomanip>
|
2018-02-01 22:20:26 +01:00
|
|
|
#include <nlohmann/json.hpp>
|
2016-12-11 13:36:08 +01:00
|
|
|
|
|
|
|
using json = nlohmann::json;
|
2022-07-31 17:38:52 +02:00
|
|
|
using namespace nlohmann::literals;
|
2016-12-11 13:36:08 +01:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// create a JSON value
|
|
|
|
json j = R"({"compact": true, "schema": 0})"_json;
|
|
|
|
|
|
|
|
// serialize it to MessagePack
|
2021-12-29 13:41:01 +01:00
|
|
|
std::vector<std::uint8_t> v = json::to_msgpack(j);
|
2016-12-11 13:36:08 +01:00
|
|
|
|
|
|
|
// print the vector content
|
|
|
|
for (auto& byte : v)
|
|
|
|
{
|
|
|
|
std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
|
|
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
}
|