line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::TraitFor::Request::DecodedParams::JSON; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4969
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use namespace::autoclean; |
5
|
|
|
|
|
|
|
use JSON::Any; |
6
|
|
|
|
|
|
|
use Try::Tiny; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Catalyst::TraitFor::Request::DecodedParams'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _build_params_decoder { return JSON::Any->new(allow_nonref => 1) } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _do_decode_params { |
15
|
|
|
|
|
|
|
my ( $self, $params ) = @_; |
16
|
|
|
|
|
|
|
my $decoder = $self->_params_decoder; |
17
|
|
|
|
|
|
|
my $decoded_param = { %$params }; |
18
|
|
|
|
|
|
|
foreach my $key ( keys %$decoded_param ) { |
19
|
|
|
|
|
|
|
my $value = $decoded_param->{$key}; |
20
|
|
|
|
|
|
|
$decoded_param->{$key} = try { $decoder->from_json($value) } |
21
|
|
|
|
|
|
|
catch { $decoder->from_json( $decoder->to_json($value) ) }; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
return $decoded_param; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__END__ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Catalyst::TraitFor::Request::DecodedParams::JSON |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use CatalystX::RoleApplicator; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__PACKAGE__->apply_request_class_roles(qw/ |
39
|
|
|
|
|
|
|
Catalyst::TraitFor::Request::DecodedParams::JSON |
40
|
|
|
|
|
|
|
/); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 AUTHOR & LICENSE |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
See L<Catalyst::TraitFor::Request::DecodedParams>. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |