line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Action::Serialize::JSON; |
2
|
|
|
|
|
|
|
$Catalyst::Action::Serialize::JSON::VERSION = '1.20'; |
3
|
2
|
|
|
2
|
|
697
|
use Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
4
|
2
|
|
|
2
|
|
13075
|
use namespace::autoclean; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
18
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'Catalyst::Action'; |
7
|
2
|
|
|
2
|
|
149
|
use JSON::MaybeXS qw(JSON); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
544
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has encoder => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
lazy_build => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _build_encoder { |
15
|
5
|
|
|
5
|
|
9
|
my $self = shift; |
16
|
5
|
|
|
|
|
26
|
return JSON->new->utf8->convert_blessed; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub execute { |
20
|
5
|
|
|
5
|
1
|
53
|
my $self = shift; |
21
|
5
|
|
|
|
|
11
|
my ( $controller, $c ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $stash_key = ( |
24
|
|
|
|
|
|
|
$controller->{'serialize'} ? |
25
|
|
|
|
|
|
|
$controller->{'serialize'}->{'stash_key'} : |
26
|
5
|
|
50
|
|
|
29
|
$controller->{'stash_key'} |
27
|
|
|
|
|
|
|
) || 'rest'; |
28
|
5
|
|
|
|
|
22
|
my $output = $self->serialize( $c->stash->{$stash_key} ); |
29
|
5
|
|
|
|
|
142
|
$c->response->output( $output ); |
30
|
5
|
|
|
|
|
218
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub serialize { |
34
|
5
|
|
|
5
|
0
|
436
|
my $self = shift; |
35
|
5
|
|
|
|
|
11
|
my $data = shift; |
36
|
5
|
|
|
|
|
202
|
$self->encoder->encode( $data ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |