line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::JSON; |
2
|
73
|
|
|
73
|
|
2508665
|
use Mojo::Base -strict; |
|
73
|
|
|
|
|
121923
|
|
|
73
|
|
|
|
|
424
|
|
3
|
73
|
|
|
73
|
|
7922
|
use Mojolicious::Plugin::Vparam::Common qw(decode_json); |
|
73
|
|
|
|
|
138
|
|
|
73
|
|
|
|
|
3182
|
|
4
|
|
|
|
|
|
|
|
5
|
73
|
|
|
73
|
|
847
|
use Mojo::JSON; |
|
73
|
|
|
|
|
23768
|
|
|
73
|
|
|
|
|
14185
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub parse_json($) { |
8
|
23
|
|
|
23
|
0
|
500
|
my $str = shift; |
9
|
23
|
50
|
|
|
|
42
|
return undef unless defined $str; |
10
|
23
|
100
|
|
|
|
73
|
return undef unless length $str; |
11
|
20
|
|
|
|
|
59
|
return decode_json $str; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_json($) { |
15
|
6
|
100
|
|
6
|
0
|
16
|
return 'Wrong format' unless defined $_[0]; |
16
|
4
|
|
|
|
|
9
|
return 0; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub register { |
20
|
75
|
|
|
75
|
0
|
210
|
my ($class, $self, $app, $conf) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$app->vtype( |
23
|
|
|
|
|
|
|
json => |
24
|
6
|
|
|
6
|
|
11
|
pre => sub { parse_json $_[1] }, |
25
|
6
|
|
|
6
|
|
8
|
valid => sub { check_json $_[1] }, |
26
|
75
|
|
|
|
|
642
|
); |
27
|
|
|
|
|
|
|
|
28
|
75
|
|
|
|
|
297
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |