JSON-SCHEMA-EVAL(1p)

πŸ“¦
version 0.642 Β· 4 versions
, in ubuntu stonking

πŸ’– json-schema-eval β€” a whole CLI for JSON::Schema::Modern::evaluate() πŸ’–

okay bestie, so this is json-schema-eval, manual section 1p, and it lives in the User Contributed Perl Documentation corner of the universe. she's a command-line interface to JSON::Schema::Modern::evaluate() and honestly? she eats. let's get into it 🫢


✨ NAME ✨

json-schema-eval β€” a command-line interface to JSON::Schema::Modern::evaluate()

bestie. it's the CLI. that's the whole vibe. 🌸


🌈 VERSION 🌈

version 0.642

ok so the version numbering here goes up linearly, one at a time, no drama. and like β€” do not read anything into the number being less than 1.0. no meaning should be presumed or inferred from that, fr fr. it's just a number bestie, it's not a vibe check on maturity. πŸ’…


πŸŽ€ 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> ] ]

the backslashes mean "keep going, we're not done". iconic behavior honestly. πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

so. this is a command-line interface to "evaluate" in JSON::Schema::Modern. that's it, that's the summary, and yet β€” the demo is where it gets good.

imagine data.json containing:

{"hello": 42.1}

and schema.json containing:

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

now run:

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

which produces the 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
}

like. the schema said "string or integer bestie" and the data said 42.1 which is a number and therefore not it. caught. gagged. πŸ’€

or, alternatively, run:

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

which produces the output:

{
  "valid": true
}

and now the exit-value tea, because this is important: 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. write that down, it's on the exam. πŸ“


✨ OPTIONS ✨

ok so real talk: every boolean and string option used as constructors to JSON::Schema::Modern is available here too. the ones below are the extra CLI-specific ones, plus the synopsis flexes. πŸ’–
  • --help β€” you know what this does bestie, it shows you the help. πŸ™ˆ
  • --specification-version, version <version> β€” pick which specification version you're working with, via --specification-version or the shorter version. πŸ‘‘
  • --output-format <format> β€” tell it what <format> you want your output in. πŸŽ€
  • --short-circuit β€” bounce out early instead of finishing the whole traversal. efficiency queen. ⚑
  • --max-traversal-depth <depth> β€” cap how deep it goes at <depth>, for when the recursion was getting a lil too main character. πŸŒ€
  • --validate-formats β€” turn on format validation. βœ…
  • --validate-content-schemas β€” turn on content-schema validation. βœ…
  • --collect-annotations β€” go collect those annotations, bestie. ✨
  • --strict β€” strict mode. no nonsense, no vibes, just strictness. πŸ’…
  • --dump-identifiers β€” dump out the identifiers. πŸ—‚οΈ
  • --with-defaults β€” bring the defaults along for the ride. 🫢
  • --validate-schema [ <filename> ] [ ... ] β€” validate a schema instead of evaluating data against one. more on this below ⬇️
  • --add-schema [ <filename> ] [ ... ] β€” add extra schemas you wanna reference via $ref. more below ⬇️
  • --data [ <filename> ] [ ... ] β€” provide the file with a JSON- or YAML-encoded data instance. more below ⬇️
  • --schema [ <filename> ] β€” provide the file with a JSON- or YAML-encoded schema. more below ⬇️

πŸ¦‹ okay now the actual option lore πŸ¦‹

so besides all those constructor options from JSON::Schema::Modern, --data is what you use to hand over the filename containing a JSON- or YAML-encoded data instance, and --schema is what you use to hand over the filename containing a JSON- or YAML-encoded schema.

and here's the slay part: you can use --data more than once to validate multiple data instances against the same schema. one schema, many datas, we love a multi-tasking icon. πŸ‘‘

if either or both of these are not provided? STDIN becomes the input. no filename, no problem. 🫢

both JSON- and YAML-encoded data and schemas are supported, and it picks between them using heuristics based on the content of the first line of the data. so don't be weird with your first line, bestie. πŸ‘€


🌸 --validate-schema 🌸

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 then gets evaluated against its meta-schema for the corresponding specification version. so it's schemas validating schemas. it's giving inception. πŸŒ€

and yes, you can use this option more than once to validate multiple schemas in the same runtime instance. iconic. πŸ’…


⭐ --add-schema ⭐

got extra schemas you wanna use via the $ref keyword? add them with --add-schema <filename>.

real talk warning bestie: the actual filename is insignificant. do not rely on it. make sure you use an $id keyword within that schema that matches the value you use in the $ref. that's the connection. that's the matchup. don't skip it. 😭

this option can be used more than once. collect them all. πŸŽ€


πŸ“ AVAILABILITY πŸ“

this executable is available on modern Debian versions (via "apt-get") as the "libjson-schema-modern-perl" package. so if you're on Debian, go get her. 🫢


πŸ’– GIVING THANKS πŸ’–

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

genuinely, a +1 and a ⭐ cost you nothing and mean everything. do it for the girlies. πŸ₯Ή


🧚 SUPPORT 🧚

bugs may be submitted through <https://github.com/karenetheridge/JSON-Schema-Modern/issues>. that's the spot. πŸ›

she's also usually active on irc, as 'ether' at "irc.perl.org" and "irc.libera.chat". so you can literally just. go talk to her. 😭

you can also find her on the JSON Schema Slack server at <https://json-schema.slack.com> and the OpenAPI Slack server at <https://open-api.slack.com>, which are also great resources for finding help. two slacks, double the support, no cap. πŸ’¬


πŸ‘‘ AUTHOR πŸ‘‘

Karen Etheridge <ether@cpan.org>

the icon herself. 🌟


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. so check that file if you're poking at the schemas specifically, bestie. πŸ“„


πŸŽ€ and that's the page πŸŽ€

perl v5.40.1 Β· 2026-07-31 Β· JSON-SCHEMA-EVAL(1p) β€” that's the version and the date at the bottom, folded into this lil sign-off instead of a boring footer. slay, go validate something. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from