line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::JSON; |
2
|
72
|
|
|
72
|
|
2138377
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
8067
|
|
|
72
|
|
|
|
|
517
|
|
3
|
72
|
|
|
72
|
|
8066
|
use Mojolicious::Plugin::Vparam::Common qw(decode_json); |
|
72
|
|
|
|
|
156
|
|
|
72
|
|
|
|
|
3320
|
|
4
|
|
|
|
|
|
|
|
5
|
72
|
|
|
72
|
|
881
|
use Mojo::JSON; |
|
72
|
|
|
|
|
13051
|
|
|
72
|
|
|
|
|
15150
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub parse_json($) { |
8
|
14
|
|
|
14
|
0
|
532
|
my $str = shift; |
9
|
14
|
50
|
|
|
|
50
|
return undef unless defined $str; |
10
|
14
|
100
|
|
|
|
66
|
return undef unless length $str; |
11
|
12
|
|
|
|
|
59
|
return decode_json $str; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_json($) { |
15
|
6
|
100
|
|
6
|
0
|
22
|
return 'Wrong format' unless defined $_[0]; |
16
|
4
|
|
|
|
|
16
|
return 0; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub register { |
20
|
74
|
|
|
74
|
0
|
231
|
my ($class, $self, $app, $conf) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$app->vtype( |
23
|
|
|
|
|
|
|
json => |
24
|
6
|
|
|
6
|
|
18
|
pre => sub { parse_json $_[1] }, |
25
|
6
|
|
|
6
|
|
16
|
valid => sub { check_json $_[1] }, |
26
|
74
|
|
|
|
|
754
|
); |
27
|
|
|
|
|
|
|
|
28
|
74
|
|
|
|
|
337
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |