How can I check if JSON data conforms to JSON Schema specification?

I have JSON data in a file named B.json and another file using a JSON schema called BSchema.json.

I would like to know how to check if JSON Data meets the JSON Schema specifications, for example on Ubuntu and Windows I can use xmllint from the command line to check the same using the following command: xmllint --schema XMLSchemaFile.xsd --noout DataFile.xml

So, is there any alternative to this command (on Linux or Windows) which allows me to input two files and check if the JSON data matches the JSON schema?

Note. If there is any other command on macOS please add to your answer, so the questions will be helpful for users of all platforms.

Thanks in advance.

+3


source to share


3 answers


Since version 2.4, jsonschema includes a command line program to check some input json file against a schema specified in another file.

You can call it like this:

jsonschema -i B.json BSchema.json

      



Here's an example from the output when I put an object where the array should be:

{u'description ': collection of u'Doubles resources.'}: {u'description ': collection of u'Doubles resources.'} is not of type u'array '

0


source


There are many command line tools available that will allow you to check json against json schema

If it's a one-off thing, you can look at the json-spec . But I found there are no links to the following links in the json schema.



But if you want a CI tool and you are using node.js / grunt as your dev environment then use tv4 and its rough job grunt-tv4

0


source


Here is a web tool that wants to do what you want: http://jsonschemalint.com/

It builds on this library: https://github.com/garycourt/JSV

Hope this helps!

-1


source







All Articles