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