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