line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::JSON; |
2
|
72
|
|
|
72
|
|
2013492
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
7591
|
|
|
72
|
|
|
|
|
459
|
|
3
|
72
|
|
|
72
|
|
6932
|
use Mojolicious::Plugin::Vparam::Common qw(decode_json); |
|
72
|
|
|
|
|
139
|
|
|
72
|
|
|
|
|
2840
|
|
4
|
|
|
|
|
|
|
|
5
|
72
|
|
|
72
|
|
812
|
use Mojo::JSON; |
|
72
|
|
|
|
|
12802
|
|
|
72
|
|
|
|
|
13540
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub parse_json($) { |
8
|
14
|
|
|
14
|
0
|
372
|
my $str = shift; |
9
|
14
|
50
|
|
|
|
39
|
return undef unless defined $str; |
10
|
14
|
100
|
|
|
|
46
|
return undef unless length $str; |
11
|
12
|
|
|
|
|
41
|
return decode_json $str; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_json($) { |
15
|
6
|
100
|
|
6
|
0
|
17
|
return 'Wrong format' unless defined $_[0]; |
16
|
4
|
|
|
|
|
10
|
return 0; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub register { |
20
|
74
|
|
|
74
|
0
|
209
|
my ($class, $self, $app, $conf) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$app->vtype( |
23
|
|
|
|
|
|
|
json => |
24
|
6
|
|
|
6
|
|
14
|
pre => sub { parse_json $_[1] }, |
25
|
6
|
|
|
6
|
|
14
|
valid => sub { check_json $_[1] }, |
26
|
74
|
|
|
|
|
678
|
); |
27
|
|
|
|
|
|
|
|
28
|
74
|
|
|
|
|
304
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |