本文介绍了如何从命令行运行json-schema-validator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从命令行运行json-schema-validator?

Is it possible to run the json-schema-validator from the command line?

是否存在用于json-schema-validator的jar文件?我在以下位置找到了一个罐子:

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]

,但是它似乎已损坏/不完整/某物(我不是Java程序员).将java.exe应用于jar文件:

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

导致此错误消息:

 "no main manifest attribute, in json-schema-validator-2.1.8.jar"

那是什么意思?

这是我的问题:

  1. 在哪里可以获取json-schema-validator的正确jar文件?

  1. Where can I obtain the correct jar file for json-schema-validator?

一旦获得jar文件,如何在命令行上使用它来针对json模式文件验证json文件?也就是说,在命令行上,我想输入以下内容:

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

并使验证器针对 schema.json 验证 instance.json 并在命令行上显示验证结果.

and have the validator validate instance.json against schema.json and display the results of the validation on the command line.

谢谢!

推荐答案

好吧,从2.1.10版本开始,您实际上可以这样做.项目自述文件中提供了说明.这是当前版本的帮助:

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

这篇关于如何从命令行运行json-schema-validator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 09:17