#include #include "nlohmann/json.hpp" int main(int argc, char *argv[]) { if (argc < 2) printf("Usage : cbor2json file.cbor file.json\n"); // Read file std::vector cbor_data; std::ifstream in_file(argv[1], std::ios::binary); while (!in_file.eof()) { uint8_t b; in_file.read((char *)&b, 1); cbor_data.push_back(b); } in_file.close(); cbor_data.pop_back(); nlohmann::json contents = nlohmann::json::from_cbor(cbor_data); std::ofstream output_file(argv[2], std::ios::binary); output_file << contents.dump(4); output_file.close(); }