use 5.008009;
use strict;
use warnings;
package Types::JsonCoercions;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.001';
use Type::Library 1.004
-base,
-declare => qw( ArrayRefJ HashRefJ
JSON;
sub _code_to_load_package {
my ( $me, $pkg, $keyword ) = ( shift, @_ );
$keyword ||= 'do';
return sprintf(
'%s { require %s; q[%s] }',
$keyword,
$pkg,
$pkg,
);
}
sub _code_for_json
'$%s::JSON ||= ( %s or %s )->new',
$me,
$me->_code_to_load_package( 'JSON::MaybeXS', 'eval' ),
$me->_code_to_load_package( 'JSON::PP' ),
);
}
my $meta = __PACKAGE__->meta;
my $ToJson = $met