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:
Answer from cgmb on Stack Overflow{u'description': u'Doubles resource collection.'}: {u'description': u'Doubles resource collection.'} is not of type u'array'
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'
In Powershell Core there is a built-in method that allows you to do the validation test-json. PowerShell syntax: Test-Json [-Json] <String> [[-Schema] <String>]. For more information have a look here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/test-json
In the question it was also asked about the environments. Powershell Core v.7.0+ is cross-platform so this validation can be done anywhere. If you can't or don't want to use PowerShell you can try some Python tool like this: Validate JSON file syntax in shell script without installing any package
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
Also you can try build and install C++ https://bitbucket.org/gallen/libvariant tool, that solve your problem.
Cli command - varsh
» pip install jsonschema-cli
» npm install jsonschema-cli
» npm install jsonschema-commandline