:jsonschema;
&usage if @ARGV < 2;
my $schema_file = shift;
my $app = App::jsonschema->new( schema_file => $schema_file );
$app->validate(@ARGV);
sub usage {
print STDERR "Usage: $0 schema.json
file1.json [file2.json ...]\n";
exit 1;
}
# ABSTRACT: Validate JSON files using JSON Schema
# PODNAME: jsonschema.pl
__END__
=pod
=encoding utf-8
=head1 NAME
jsonschema.pl - Validate JSON file
s using JSON Schema
=head1 VERSION
version 0.03
=head1 SYNOPSIS
jsonschema.pl schema.json file1.json [file2.json ...]
=head1 SEE ALSO
L<App::jsonschema>, L<JSON>, L<JSON::Schema>
=head1 AUTHOR
use strict;
use warnings;
package App::jsonschema;
{
$App::jsonschema::VERSION = '0.03';
}
use JSON::Schema;
use JSON qw/from_json/;
use autodie;
use Moo;
use feature qw/say/;
use Data::Dump qw/dump
/;
# ABSTRACT: Command-line utility to validate JSON using JSON Schema
has schema_file => (
is => 'rw',
required => 1,
isa => sub { die "Could not find file '$_[0]'!" unless -f $_[0] }
'lazy' );
has validator => ( is => 'lazy' );
sub _build_validator {
my $self = shift;
return JSON::Schema->new($self->schema);
}
sub _build_schema {
my $self = shift;
my $schema;
{
local $/