line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Entity::Parser::JSON; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
71841
|
use strict; |
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
157
|
|
4
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
63
|
|
|
5
|
|
|
|
|
170
|
|
5
|
5
|
|
|
5
|
|
1976
|
use JSON::MaybeXS qw/decode_json/; |
|
5
|
|
|
|
|
25020
|
|
|
5
|
|
|
|
|
297
|
|
6
|
5
|
|
|
5
|
|
2785
|
use Encode qw/encode_utf8/; |
|
5
|
|
|
|
|
72636
|
|
|
5
|
|
|
|
|
2015
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
96
|
bless [''], $_[0]; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub add { |
13
|
7
|
|
|
7
|
0
|
25
|
my $self = shift; |
14
|
7
|
50
|
|
|
|
20
|
if (defined $_[0]) { |
15
|
7
|
|
|
|
|
19
|
$self->[0] .= $_[0]; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub finalize { |
20
|
1
|
|
|
1
|
0
|
5
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
16
|
my $p = decode_json($self->[0]); |
23
|
1
|
|
|
|
|
2
|
my @params; |
24
|
1
|
50
|
|
|
|
5
|
if (ref $p eq 'HASH') { |
25
|
1
|
|
|
|
|
6
|
while (my ($k, $v) = each %$p) { |
26
|
5
|
|
|
|
|
12
|
push @params, _encode($k), _encode($v); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
1
|
|
|
|
|
7
|
return (\@params, []); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _encode { |
33
|
20
|
|
|
20
|
|
36
|
my ($data) = @_; |
34
|
|
|
|
|
|
|
|
35
|
20
|
100
|
|
|
|
51
|
if (ref $data eq "ARRAY") { |
|
|
100
|
|
|
|
|
|
36
|
2
|
|
|
|
|
2
|
my @result; |
37
|
2
|
|
|
|
|
8
|
for my $d (@$data) { |
38
|
4
|
|
|
|
|
10
|
push @result, _encode($d); |
39
|
|
|
|
|
|
|
} |
40
|
2
|
|
|
|
|
11
|
return \@result; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif (ref $data eq "HASH") { |
43
|
3
|
|
|
|
|
5
|
my %result; |
44
|
3
|
|
|
|
|
12
|
while (my ($k, $v) = each %$data) { |
45
|
3
|
|
|
|
|
8
|
$result{_encode($k)} = _encode($v); |
46
|
|
|
|
|
|
|
} |
47
|
3
|
|
|
|
|
10
|
return \%result; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
15
|
50
|
|
|
|
63
|
return defined $data ? encode_utf8($data) : undef; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |