2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-04 20:37:50 +00:00
qpdf/libtests/json_parse.cc

28 lines
639 B
C++
Raw Normal View History

2022-01-17 23:40:38 +00:00
#include <qpdf/JSON.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
int main(int argc, char* argv[])
{
if (argc != 2)
{
std::cerr << "Usage: json_parse file" << std::endl;
return 2;
}
char const* filename = argv[1];
try
{
PointerHolder<char> buf;
size_t size;
QUtil::read_file_into_memory(filename, buf, size);
std::string s(buf.get(), size);
2022-01-17 23:40:38 +00:00
std::cout << JSON::parse(s).unparse() << std::endl;
}
catch (std::exception& e)
{
std::cerr << "exception: " << filename<< ": " << e.what() << std::endl;
return 2;
}
return 0;
}