问题
Is it possible to run the json-schema-validator from the command line?
Is there a jar file for json-schema-validator? I found a jar at:
[http://mvnrepository.com/artifact/com.github.fge/json-schema-validator/2.1.8][1]
but it appears to be corrupt/incomplete/something (I'm not a Java programmer). Applying java.exe to the jar file:
java -jar json-schema-validator-2.1.8.jar
results in this error message:
"no main manifest attribute, in json-schema-validator-2.1.8.jar"
What does that mean?
Here are my questions:
Where can I obtain the correct jar file for json-schema-validator?
Once I obtain the jar file, how do I use it on a command line to validate a json file against a json-schema file? That is, on the command line I would like to type something like this:
java -jar json-schema-validator-2.1.8.jar instance.json schema.json
and have the validator validate instance.json against schema.json and display the results of the validation on the command line.
Thanks!
回答1:
OK, since version 2.1.10 you can actually do that. Instructions are provided in the README of the project. Here is the help of the current version:
$ java -Done-jar.silent=true -jar json-schema-validator-2.1.10-standalone.jar --help
Syntax: java -jar jsonschema.jar [options] file [file...]
Options:
-s, --brief: only show validation status (OK/NOT OK)
--help: show this help
-q, --quiet: no output; exit with the relevant return code (see below)
--syntax: check the syntax of schema(s) given as argument(s)
Exit codes:
0: validation successful;
1: exception occurred (appears on stderr)
2: command line syntax error (missing argument, etc)
100: one or more file(s) failed validation
101: one or more schema(s) is/are invalid
回答2:
Also you can try build and install C++ https://bitbucket.org/gallen/libvariant tool, that solve your problem.
Cli command - varsh
来源:https://stackoverflow.com/questions/22867521/how-to-run-json-schema-validator-from-the-command-line