.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "JSON::Validator::Store 3pm" .TH JSON::Validator::Store 3pm "2023-03-06" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" JSON::Validator::Store \- Load and caching JSON schemas .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& 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"); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" JSON::Validator::Store is a class for loading and caching JSON-Schemas. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "cache_paths" .IX Subsection "cache_paths" .Vb 2 \& my $store = $store\->cache_paths(\e@paths); \& my $array_ref = $store\->cache_paths; .Ve .PP A list of directories to where cached specifications are stored. Defaults to \&\f(CW\*(C`JSON_VALIDATOR_CACHE_PATH\*(C'\fR environment variable and the specs that is bundled with this distribution. .PP \&\f(CW\*(C`JSON_VALIDATOR_CACHE_PATH\*(C'\fR can be a list of directories, each separated by \*(L":\*(R". .PP See \*(L"Bundled specifications\*(R" in JSON::Validator for more details. .SS "schemas" .IX Subsection "schemas" .Vb 2 \& my $hash_ref = $store\->schemas; \& my $store = $store\->schemas({}); .Ve .PP Hold the schemas as data structures. The keys are schema \*(L"id\*(R". .SS "ua" .IX Subsection "ua" .Vb 2 \& my $ua = $store\->ua; \& my $store = $store\->ua(Mojo::UserAgent\->new); .Ve .PP Holds a Mojo::UserAgent object, used by \*(L"schema\*(R" to load a \s-1JSON\s0 schema from remote location. .PP The default Mojo::UserAgent will detect proxy settings and have \&\*(L"max_redirects\*(R" in Mojo::UserAgent set to 3. .SH "METHODS" .IX Header "METHODS" .SS "add" .IX Subsection "add" .Vb 1 \& my $normalized_id = $store\->add($id => \e%schema); .Ve .PP Used to add a schema data structure. Note that \f(CW$id\fR might not be the same as \&\f(CW$normalized_id\fR. .SS "exists" .IX Subsection "exists" .Vb 1 \& my $normalized_id = $store\->exists($id); .Ve .PP Returns a \f(CW$normalized_id\fR if it is present in the \*(L"schemas\*(R". .SS "get" .IX Subsection "get" .Vb 1 \& my $schema = $store\->get($normalized_id); .Ve .PP Used to retrieve a \f(CW$schema\fR added by \*(L"add\*(R" or \*(L"load\*(R". .SS "load" .IX Subsection "load" .Vb 8 \& my $normalized_id = $store\->load(\*(Aqhttps://...\*(Aq); \& my $normalized_id = $store\->load(\*(Aqdata://main/foo.json\*(Aq); \& my $normalized_id = $store\->load(\*(Aq\-\-\-\enid: yaml\*(Aq); \& my $normalized_id = $store\->load(\*(Aq{"id":"yaml"}\*(Aq); \& my $normalized_id = $store\->load(\e$text); \& my $normalized_id = $store\->load(\*(Aq/path/to/foo.json\*(Aq); \& my $normalized_id = $store\->load(\*(Aqfile:///path/to/foo.json\*(Aq); \& my $normalized_id = $store\->load(\*(Aq/load/from/ua\-server\-app\*(Aq); .Ve .PP Can load a \f(CW$schema\fR from many different sources. The input can be a string or a string-like object, and the \*(L"load\*(R" method will try to resolve it in the order listed in above. .PP Loading schemas from \f(CW$text\fR will generate an \f(CW$normalized_id\fR in \*(L"schemas\*(R" looking like \*(L"urn:text:$text_checksum\*(R". This might change in the future! .PP Loading files from disk will result in a \f(CW$normalized_id\fR that always start with \*(L"file://\*(R". .PP Loading can also be done with relative path, which will then load from: .PP .Vb 1 \& $store\->ua\->server\->app; .Ve .PP This method is \s-1EXPERIMENTAL,\s0 but unlikely to change significantly. .SS "resolve" .IX Subsection "resolve" .Vb 1 \& $hash_ref = $store\->resolve($url, \e%defaults); .Ve .PP Takes a \f(CW$url\fR (can also be a file, urn, ...) with or without a fragment and returns this structure about the schema: .PP .Vb 7 \& { \& 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 \& } .Ve .PP This method is \s-1EXPERIMENTAL\s0 and can change without warning. .SH "SEE ALSO" .IX Header "SEE ALSO" JSON::Validator.