get_binary.cpp 408 B

12345678910111213141516
  1. #include <iostream>
  2. #include <nlohmann/json.hpp>
  3. using json = nlohmann::json;
  4. int main()
  5. {
  6. // create a binary vector
  7. std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE};
  8. // create a binary JSON value with subtype 42
  9. json j = json::binary(vec, 42);
  10. // output type and subtype
  11. std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
  12. }