simdjson/tools/minify.cpp

22 lines
543 B
C++
Raw Normal View History

2018-09-28 12:00:52 +08:00
#include <iostream>
2018-11-30 22:37:57 +08:00
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonminifier.h"
2018-09-28 12:00:52 +08:00
int main(int argc, char *argv[]) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <jsonfile>\n";
exit(1);
}
2019-07-03 03:21:00 +08:00
simdjson::padded_string p;
2018-12-01 09:27:16 +08:00
std::string filename = argv[argc - 1];
try {
2019-07-03 03:21:00 +08:00
simdjson::get_corpus(filename).swap(p);
2019-08-01 05:43:45 +08:00
} catch (const std::exception &) {
std::cout << "Could not load the file " << filename << std::endl;
return EXIT_FAILURE;
2018-12-01 09:27:16 +08:00
}
simdjson::json_minify(p, p.data());
printf("%s", p.data());
2018-09-28 12:00:52 +08:00
}