JSON-Relaxed
view release on metacpan or search on metacpan
scripts/rrjson.pl view on Meta::CPAN
elsif ( $mode eq "rjson" ) {
print $parser->encode( data => $data,
strict => 1,
indent => $indent,
maybe schema => $schema );
print "\n" unless $pretty;
}
elsif ( $mode eq "json_xs" ) {
require JSON::XS;
print ( JSON::XS->new->canonical->utf8(0)->pretty($pretty)
->boolean_values( $JSON::PP::false, $JSON::PP::true )
->convert_blessed->encode($data) );
}
elsif ( $mode eq "toml" ) {
require TOML::Tiny;
my $parser = TOML::Tiny->new();
print ( TOML::Tiny::to_toml($data) );
}
elsif ( $mode eq "yaml" ) {
require YAML;
$YAML::UseAliases = 0;
$YAML::Stringify = 1;
print ( YAML::Dump($data) );
}
else { # default JSON
require JSON::PP;
print ( JSON::PP->new->canonical->utf8(0)->pretty($pretty)
->boolean_values( $JSON::PP::false, $JSON::PP::true )
->convert_blessed->encode($data) );
}
}
################ Subroutines ################
package Data::Properties {
sub __data_internal {
my ( $self, $orig ) = @_;
t/99_regtest.t view on Meta::CPAN
my @files = @ARGV;
@files = sort glob("*.rjson") unless @files;
my $tests = 0;
my $pp = JSON::PP->new;
my $p = JSON::Relaxed->new( croak_on_error => 0 );
# So we can compare the boolen values of RJSON and JSON.
$p->booleans = [qw{F T}];
$pp->boolean_values(qw(F T));
foreach my $rjsonfile ( @files ) {
# Load the file.
my $opts = { split => 0, fail => "soft" };
my $rjsondata = loadlines( $rjsonfile, $opts );
ok( $rjsondata, "$rjsonfile - load" ); $tests++;
diag( "$rjsonfile: " . $opts->{error} ) if $opts->{error};
next unless $rjsondata;
( run in 0.201 second using v1.01-cache-2.11-cpan-9ff20fc0ed8 )