the type of the incoming value.
Example blatantly stolen from the Moose documentation:
sub to_json
{
my $value = shift;
return match_on_type $value => (
HashRef() =>
to_json( $hash->{$_} ) }
sort keys %$hash
) . ' }';
},
ArrayRef() => sub {
my $array = shift;
'[ '.( join ", " => map { to_json($_
q { '"' . $_ . '"' },
Undef() => q {'null'},
=> sub { die "$_ is not acceptable json type" },
);
}
Note that unlike Moose, code can be specified as a string instead of a
co
t resort, you can manually install it. Download the tarball and
unpack it.
Consult the file META.json for a list of pre-requisites. Install these
first.
To build Type-Tiny:
% perl Makefile.PL
%
als => { username => 'bob', password => 's3cr3t' },
headers => { 'Accept' => 'application/json' },
url => 'http://example.net/api/v1/stuff',
method => 'GET',
} );
It's
verload
fallbacks may actually be useless as a practical boolean. But some common
objects such as JSON::PP's booleans overload "0+" instead of overloading
"bool" (thankfully with fallbacks enabled!) s
on of this type is to be a version of B<Bool> which also
accepts common boolean objects such as L<JSON::PP::Boolean>. It is currently
unstable and the exact definition of the type may change to better