Add simple json validator application
This commit is contained in:
parent
4ab352036d
commit
937d9522e0
11
Makefile.am
11
Makefile.am
@ -104,7 +104,8 @@ libutil_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
libutil_la_LIBADD = $(BOOST_SYSTEM_LIB)
|
||||
|
||||
bin_PROGRAMS = \
|
||||
json-clean
|
||||
json-clean \
|
||||
json-validate
|
||||
|
||||
json_clean_SOURCES = json/clean.cpp
|
||||
json_clean_DEPENDENCIES = $(top_builddir)/.libs/libutil.la
|
||||
@ -112,3 +113,11 @@ json_clean_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
$(BOOST_FILESYSTEM_LIB) \
|
||||
$(top_builddir)/.libs/libutil.a
|
||||
|
||||
|
||||
json_validate_SOURCES = json/validate.cpp
|
||||
json_validate_DEPENDENCIES = $(top_builddir)/.libs/libutil.la
|
||||
json_validate_LDFLAGS = \
|
||||
$(BOOST_LDFLAGS) \
|
||||
$(BOOST_FILESYSTEM_LIB) \
|
||||
$(top_builddir)/.libs/libutil.a
|
||||
|
33
json/validate.cpp
Normal file
33
json/validate.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#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::parse (boost::filesystem::path (argv[ARG_PATH]));
|
||||
} catch (json::error &x) {
|
||||
std::cerr << x.what () << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user