mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
25 lines
634 B
C++
25 lines
634 B
C++
#include <fstream>
|
|
#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<uint8_t> 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();
|
|
}
|