line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::AutoCRUD::View::Json; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
593
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
7
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
extends 'App::AutoCRUD::View'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7227
|
use JSON::MaybeXS; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
87
|
|
8
|
1
|
|
|
1
|
|
8
|
use namespace::clean -except => 'meta'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'json_args' => ( is => 'bare', isa => 'HashRef', |
11
|
|
|
|
|
|
|
default => sub {{ pretty => 1, |
12
|
|
|
|
|
|
|
allow_blessed => 1, |
13
|
|
|
|
|
|
|
convert_blessed => 1 }} ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub render { |
17
|
2
|
|
|
2
|
0
|
8
|
my ($self, $data, $context) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# encode output |
20
|
2
|
|
|
|
|
6
|
my $json_maker = JSON::MaybeXS->new(%{$self->{json_args}}); |
|
2
|
|
|
|
|
26
|
|
21
|
2
|
|
|
|
|
221
|
my $output = $json_maker->encode($data); |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
77
|
return [200, ['Content-type' => 'application/json; charset=UTF-8'], |
24
|
|
|
|
|
|
|
[$output] ]; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|