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