Scroll to navigation

JSON-SCHEMA-EVAL(1p) User Contributed Perl Documentation JSON-SCHEMA-EVAL(1p)

NAME

json-schema-eval - A command-line interface to JSON::Schema::Modern::evaluate()

VERSION

version 0.630

SYNOPSIS

  json-schema-eval --help
  json-schema-eval \
    [ --specification-version|version <version> ] \
    [ --output-format <format> ] \
    [ --short-circuit ] \
    [ --max-traversal-depth <depth> ] \
    [ --validate-formats ] \
    [ --validate-content-schemas ] \
    [ --collect-annotations ] \
    [ --strict ] \
    [ --dump-identifiers ] \
    [ --with-defaults ] \
    [ --validate-schema [ <filename> ] [ ... ] ] \
    [ --add-schema [ <filename> ] [ ... ] ] \
    [ --data [ <filename> ] [ ... ] ] \
    [ --schema [ <filename> ] ]

DESCRIPTION

A command-line interface to "evaluate" in JSON::Schema::Modern.

data.json contains:

  {"hello": 42.1}

schema.json contains:

  {"properties": {"hello": {"type": ["string", "integer"]}}}

Run:

  json-schema-eval --data data.json --schema schema.json

produces output:

  {
    "errors" : [
      {
        "error" : "got number, not one of string, integer",
        "instanceLocation" : "/hello",
        "keywordLocation" : "/properties/hello/type"
      },
      {
        "error" : "not all properties are valid",
        "instanceLocation" : "",
        "keywordLocation" : "/properties"
      }
    ],
    "valid" : false
  }

Or run:

  json-schema-eval --validate-schema schema.json

produces output:

  {
    "valid": true
  }

The exit value ($?) is 0 when the result is valid, 1 when it is invalid, and some other non-zero value if an exception occurred.

OPTIONS

All boolean and string options used as constructors to JSON::Schema::Modern are available.

Additionally, "--data" is used to provide the filename containing a JSON- or YAML-encoded data instance, and "--schema" provides the filename containing a JSON- or YAML-encoded schema. You can use the "--data" option more than once to validate multiple data instances against the same schema.

If either or both of these are not provided, STDIN is used as input.

Both JSON- and YAML-encoded data and schemas are supported, using heuristics based on the content of the first line of the data.

Alternatively, you can use "--validate-schema" and either provide a filename containing a JSON-encoded schema, or omit the argument to read a schema from STDIN. The schema will be evaluated against its meta-schema for the corresponding specification version. You can use this option more than once to validate multiple schemas in the same runtime instance.

Additional schemas, that you wish to use via the $ref keyword, can be added with "--add-schema <filename>". The actual filename is insignificant: Make sure you use an $id keyword within that schema that matches the value you use in the $ref. This option can be used more than once.

AVAILABILITY

This executable is available on modern Debian versions (via "apt-get") as the "libjson-schema-modern-perl" package.

GIVING THANKS

If you found this module to be useful, please show your appreciation by adding a +1 in MetaCPAN <https://metacpan.org/dist/JSON-Schema-Modern> and a star in GitHub <https://github.com/karenetheridge/JSON-Schema-Modern>.

SUPPORT

Bugs may be submitted through <https://github.com/karenetheridge/JSON-Schema-Modern/issues>.

I am also usually active on irc, as 'ether' at "irc.perl.org" and "irc.libera.chat".

You can also find me on the JSON Schema Slack server <https://json-schema.slack.com> and OpenAPI Slack server <https://open-api.slack.com>, which are also great resources for finding help.

AUTHOR

Karen Etheridge <ether@cpan.org>

COPYRIGHT AND LICENCE

This software is copyright (c) 2020 by Karen Etheridge.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Some schema files have their own licence, in share/LICENSE.

2025-12-19 perl v5.40.1