Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, February 10, 2021

soljsonvalidate (1)


soljsonvalidate - validate json against json schema files


/usr/bin/soljsonvalidate [-nv] [-i pattern] [path] ...


The soljsonvalidate command loads JSON schema files and validates JSON files against those schemas.

By default, soljsonvalidate loads all schemas reachable through descent from /usr/share/lib/json/soljsonvalidate. Any schema therein will identify itself w/ the 'id' tag. Any JSON files claiming adherence to one of those schemas (w/ the '$schema' attribute) will be validated against that schema. No schemas are loaded from the default path if –n option is specified.

All paths passed to soljsonvalidate are examined. Directories are recursively examined and symbolic links traversed. Any ordinary files are queued for validation if they match a pattern specified by the –i option. The default pattern used if no –i option is specified is '*.json'.

If no paths are specified, soljsonvalidate will attempt to read JSON file from stdin and validate that.

All matching JSON files are opened and checked for JSON syntax errors. No validation is performed if syntax errors are found. Once loaded, all JSON files are validated and any new schemas found are validated against the built-in base schema.

By default, if no errors occur soljsonvalidate runs silently and exits with a 0 error code. If errors occur, appropriate error messages are printed. If the –v option is specified, soljsonvalidate prints a line for each json object successfully validated in addition to any error messages generated by json object failing validation.

Note that "/usr/bin/soljsonvalidate <path> ..." is equivalent to "/usr/bin/soljsonvalidate -n /usr/share/lib/json/soljsonvalidate <path> ..".

The output of this command, both for errors and with the –v option, is intended for human use and the format of the resulting messages is explicitly subject to change.


The following options are supported:


Does not load /usr/share/lib/json/soljsonvalidate as the first item on the path.


Prints messages for successful validations.

–i pattern

Specifies an alternate file matching pattern as described in the fnmatch(7) man page.

Exit Status


All JSON files were loaded and validated successfully.


One or more errors occurred.


Example 1 Validating a JSON File

Below is a sample JSON file, 'solaris.json':

    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "solaris-machine",
    "description": "machines on which Solaris runs",
    "type": "object",
    "properties": {
    "architecture": {
        "description": "machine CPU architecture",
        "enum": ["SPARC", "x86"]
    "number-of-sockets": {
        "type": "integer",
        "minimum": 1

     "$schema": "solaris-machine",
     "id": "M6-32",
     "architecture": "SPARC",
     "number-of-sockets": 32
     "$schema": "solaris-machine",
     "id": "not-so-far",
     "architecture": "ARM",
     "number-of-sockets": 1
     "$schema": "solaris-machine",
     "id": "missing-something-important",
     "architecture": "SPARC",
     "number-of-sockets": 0

When this file is validated by using the soljsonvalidate command, it displays the following two error messages:

bash: soljsonvalidate -n solaris.json
solaris.json: validation error: key 'architecture' does not have value ('"ARM"') contained in enum ["SPARC", "x86"]
solaris.json: validation error: key 'number-of-sockets' is 0.000000, less than minimum value 1.000000


See attributes(7) for descriptions of the following attributes:

Interface Stability
name, options, and exit codes: evolving
messages: volatile

See Also