use strict;
use warnings;
package YAML::PP::Schema::JSON;
our $VERSION = 'v0.39.0'; # VERSION
use base 'Exporter';
our @EXPORT_OK = qw/
represent_int represent_float represent_literal represent_
l') {
$empty_null = 1;
}
else {
croak "Invalid option for JSON Schema: '$opt'";
}
}
$schema->add_resolver(
tag => 'tag:yaml.org,2002:nu
ead1 NAME
YAML::PP::Schema::JSON - YAML 1.2 JSON Schema
=head1 SYNOPSIS
my $yp = YAML::PP->new( schema => ['JSON'] );
my $yp = YAML::PP->new( schema => [qw/ JSON empty=str /] );
my $yp
l') {
$empty_null = 1;
}
else {
croak "Invalid option for JSON Schema: '$opt'";
}
}
$schema->add_resolver(
tag => qr{^(?:!|tag:)},
ead1 NAME
YAML::PP::Schema::JSON - YAML 1.2 JSON Schema
=head1 SYNOPSIS
my $yp = YAML::PP->new( schema => ['JSON'] );
my $yp = YAML::PP->new( schema => [qw/ JSON empty=str /] );
my $yp
= YAML::PP->new( schema => [qw/ JSON empty=null /] );
=head1 DESCRIPTION
=cut
me qw/ basename dirname /;
use HTML::Entities qw/ encode_entities /;
use YAML::PP::Highlight;
use JSON::XS ();
use Encode;
chomp(my $version = qx{git describe --dirty});
my $yaml_test_suite = 'test-s
"#invalid">Invalid (@{[ scalar @invalid ]})</a><br>
EOM
my $ypp = YAML::PP->new(
boolean => 'JSON::PP',
schema => [qw/ Core /],
);
my $table;
for my $dir (sort @valid) {
my $test = highli
></td>
<td>YAML::PP::Highlight</td>
<td>YAML::PP::Loader | Data::Dump</td>
<td>YAML::PP::Loader | JSON::XS</td>
<td>YAML::PP::Loader | YAML::PP::Dumper</td>
<td>YAML::PP::Parser | YAML::PP::Emitter</t
;
use Data::Dumper;
use FindBin '$Bin';
use lib "$Bin/../lib";
use YAML::PP;
use JSON::PP;
$YAML::XS::Boolean = 'JSON::PP';
use YAML::XS ();
$YAML::Syck::ImplicitTyping = 1;
use YAML::Syck ();
$YAML:
) = @_;
return 'null' unless defined $value;
if (ref $value) {
if (ref $value eq 'JSON::PP::Boolean') {
return 'bool';
}
return 'unknown';
}
my $fla
ash_pm_file = "$Bin/../lib/YAML/PP/Schema/Tie/IxHash.pm";
my $yp = YAML::PP->new( schema => [qw/ JSON Perl Tie::IxHash /] );
generate(
file => $schema_perl_pm_file,
tests => $tests_perl,
);
ckage YAML::PP;
our $VERSION = 'v0.39.0'; # VERSION
use YAML::PP::Schema;
use YAML::PP::Schema::JSON;
use YAML::PP::Loader;
use YAML::PP::Dumper;
use Scalar::Util qw/ blessed /;
use Carp qw/ croak /
my $ypp = YAML::PP->new( schema => ['Failsafe'] );
# use YAML 1.2 JSON Schema
my $ypp = YAML::PP->new( schema => ['JSON'] );
# use YAML 1.2 Core Schema
my $ypp = YAML::PP->new( schem
on_directive => 0,
);
Options:
=over
=item boolean
Values: C<perl> (currently default), C<JSON::PP>, C<boolean>, C<perl_experimental>
This option is for loading and dumping.
In case of perl
{
$examples{ $input }->{ $schema } = $def;
}
}
}
my @keys = qw/ failsafe json core yaml11 /;
for my $input (sort keys %examples) {
my $schemas = $examples{ $input };
m
x->{core}->[0] } <=> $type_index{ $y->{core}->[0] }
|| $type_index{ $x->{json}->[0] } <=> $type_index{ $y->{json}->[0] }
|| lc $a cmp lc $b
|| $a cmp $b
}
sub schema_table {
? 'YAML.pm' : $_;
qq{<th colspan="2" class="border-left">$m</th>\n};
} (qw/ Failsafe JSON Core /, 'YAML 1.1', @mods);
$header .= qq{</tr>\n};
$html .= $header;
$html .= qq{<tr
{
$examples{ $input }->{ $schema } = $def;
}
}
}
my @keys = qw/ failsafe json core yaml11 /;
for my $input (sort keys %examples) {
my $schemas = $examples{ $input };
m
x->{core}->[0] } <=> $type_index{ $y->{core}->[0] }
|| $type_index{ $x->{json}->[0] } <=> $type_index{ $y->{json}->[0] }
|| lc $a cmp lc $b
|| $a cmp $b
}
sub schema_table {
? 'YAML.pm' : $_;
qq{<th colspan="2" class="border-left">$m</th>\n};
} (qw/ Failsafe JSON Core /, 'YAML 1.1');
$header .= qq{</tr>\n};
$html .= $header;
$html .= qq{<tr><td></
s;
package YAML::PP::Schema::YAML1_1;
our $VERSION = 'v0.39.0'; # VERSION
use YAML::PP::Schema::JSON qw/
represent_int represent_float represent_literal represent_bool
represent_undef
/;
us
ings;
package YAML::PP::Schema::Core;
our $VERSION = 'v0.39.0'; # VERSION
use YAML::PP::Schema::JSON qw/
represent_int represent_float represent_literal represent_bool
represent_undef
/;
us
tag => 'tag:yaml.org,2002:int',
match => [ regex => $RE_INT_CORE => \&YAML::PP::Schema::JSON::_to_int ],
);
$schema->add_resolver(
tag => 'tag:yaml.org,2002:int',
mat
g => 'tag:yaml.org,2002:float',
match => [ regex => $RE_FLOAT_CORE => \&YAML::PP::Schema::JSON::_to_float ],
);
$schema->add_resolver(
tag => 'tag:yaml.org,2002:float',
', 'JSON::PP::Boolean');
last;
}
elsif ($b eq 'JSON::PP') {
require JSON::PP;
$true ||= \&_bool_jsonpp_true;
$false ||= \&_bool_jsonpp_f
alse;
push @bool_class, 'JSON::PP::Boolean';
}
elsif ($b eq 'boolean') {
require boolean;
$true ||= \&_bool_booleanpm_true;
$false ||= \
else {
die "Invalid value for 'boolean': '$b'. Allowed: ('perl', 'boolean', 'JSON::PP')";
}
}
# Ensure booleans are resolved
$true ||= \&_bool_perl_true;
$
) {
# JSON::PP and boolean.pm always return the same reference for booleans
# Avoid printing *aliases in those case
if (ref $doc eq 'boolean' or ref $doc eq 'JSON::PP::Boolean'
use JSON ();
use JSON::PP ();
use JSON::XS ();
use Cpanel::JSON::XS ();
require Mojolicious;
use Mojo::JSON ();
use B ();
use Text::Table;
my @classes = qw/ JSON JSON::PP JSON::XS Cpanel::JSON::XS
o::JSON /;
my $t = Text::Table->new(
qw/
Class
Version
3 IV NV PV
3.140 IV NV PV
3.00 IV NV PV
0.3e3 IV NV PV
encode
/,
);
my $json =
lass eq 'Mojo::JSON' ? Mojolicious->VERSION : $class->VERSION;
my @row = ( $class, $version );
my $decode = $class->can("decode_json");
my $encode = $class->can("encode_json");
my $dat