simdjson/tools/minify.cpp

23 lines
560 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);
}
2018-12-01 10:31:05 +08:00
std::string_view p;
2018-12-01 09:27:16 +08:00
std::string filename = argv[argc - 1];
try{
p = get_corpus(filename);
} catch (const std::exception& e) {
std::cout << "Could not load the file " << filename << std::endl;
return EXIT_FAILURE;
}
2018-12-01 10:31:05 +08:00
jsonminify(p, (char *)p.data());
2018-12-01 09:27:16 +08:00
printf("%s",p.data());
aligned_free((void*)p.data());
2018-09-28 12:00:52 +08:00
}