How do I verify if JSON data satisfy a JSON Schema specification?
json, jsonschema
Solution
As of 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 so:
jsonschema -i B.json BSchema.json
Here's some example output from when I put an object where an array should be:
{u'description': u'Doubles resource collection.'}: {u'description': u'Doubles resource collection.'} is not of type u'array'
Problem
I have JSON data in a file called `B.json` and another file with a JSON schema called `BSchema.json`. I'd like to know how to verify if the JSON data satisfy the JSON Schema specification, for example, in Ubuntu and Windows I can use the `xmllint` program from the command line to verify the same using the following command: `xmllint --schema XMLSchemaFile.xsd --noout DataFile.xml`. So, is there any alternative to this command (in Linux or Windows) that allows me to input the two files and check if the JSON data satisfy the JSON Schema? Note: if there is any other command like that in MacOS, please add to your answer, so the questions will be useful for users of all platforms.