GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
JSON::Validator::Store(3) User Contributed Perl Documentation JSON::Validator::Store(3)

JSON::Validator::Store - Load and caching JSON schemas

  use JSON::Validator;
  my $jv = JSON::Validator->new;
  $jv->store->add("urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" => {...});
  $jv->store->load("http://api.example.com/my/schema.json");

JSON::Validator::Store is a class for loading and caching JSON-Schemas.

  my $store     = $store->cache_paths(\@paths);
  my $array_ref = $store->cache_paths;

A list of directories to where cached specifications are stored. Defaults to "JSON_VALIDATOR_CACHE_PATH" environment variable and the specs that is bundled with this distribution.

"JSON_VALIDATOR_CACHE_PATH" can be a list of directories, each separated by ":".

See "Bundled specifications" in JSON::Validator for more details.

  my $hash_ref = $store->schemas;
  my $store = $store->schemas({});

Hold the schemas as data structures. The keys are schema "id".

  my $ua    = $store->ua;
  my $store = $store->ua(Mojo::UserAgent->new);

Holds a Mojo::UserAgent object, used by "schema" to load a JSON schema from remote location.

The default Mojo::UserAgent will detect proxy settings and have "max_redirects" in Mojo::UserAgent set to 3.

  my $normalized_id = $store->add($id => \%schema);

Used to add a schema data structure. Note that $id might not be the same as $normalized_id.

  my $normalized_id = $store->exists($id);

Returns a $normalized_id if it is present in the "schemas".

  my $schema = $store->get($normalized_id);

Used to retrieve a $schema added by "add" or "load".

  my $normalized_id = $store->load('https://...');
  my $normalized_id = $store->load('data://main/foo.json');
  my $normalized_id = $store->load('---\nid: yaml');
  my $normalized_id = $store->load('{"id":"yaml"}');
  my $normalized_id = $store->load(\$text);
  my $normalized_id = $store->load('/path/to/foo.json');
  my $normalized_id = $store->load('file:///path/to/foo.json');
  my $normalized_id = $store->load('/load/from/ua-server-app');

Can load a $schema from many different sources. The input can be a string or a string-like object, and the "load" method will try to resolve it in the order listed in above.

Loading schemas from $text will generate an $normalized_id in "schemas" looking like "urn:text:$text_checksum". This might change in the future!

Loading files from disk will result in a $normalized_id that always start with "file://".

Loading can also be done with relative path, which will then load from:

  $store->ua->server->app;

This method is EXPERIMENTAL, but unlikely to change significantly.

  $hash_ref = $store->resolve($url, \%defaults);

Takes a $url (can also be a file, urn, ...) with or without a fragment and returns this structure about the schema:

  {
    base_url => $str,  # the part before the fragment in the $url
    fragment => $str,  # fragment part of the $url
    id       => $str,  # store ID
    root     => ...,   # the root schema
    schema   => ...,   # the schema inside "root" if fragment is present
  }

This method is EXPERIMENTAL and can change without warning.

JSON::Validator.
2022-03-18 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.