libcruft-util/tools/json-validate.cpp

34 lines
611 B
C++
Raw Normal View History

2012-04-12 14:14:33 +10:00
#include "../json.hpp"
#include <iostream>
#include <cstdlib>
#include <boost/filesystem.hpp>
enum {
ARG_CMD,
ARG_PATH,
NUM_ARGS
};
int
main (int argc, char ** argv) {
if (argc != NUM_ARGS) {
std::cerr << "Invalid arguments. "
<< argv[ARG_CMD] << " <path> "
<< std::endl;
return EXIT_FAILURE;
}
try {
json::tree::parse (boost::filesystem::path (argv[ARG_PATH]));
} catch (json::tree::error &x) {
std::cerr << "Error: " << x.what () << std::endl;
2012-04-12 14:14:33 +10:00
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}