line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::PAIA::JSON; |
2
|
4
|
|
|
4
|
|
15
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
99
|
|
3
|
4
|
|
|
4
|
|
33
|
use v5.10; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
176
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.30'; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
14
|
use parent 'Exporter'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
33
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(decode_json encode_json); |
9
|
4
|
|
|
4
|
|
2663
|
use JSON::PP qw(); |
|
4
|
|
|
|
|
38688
|
|
|
4
|
|
|
|
|
489
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub decode_json { |
12
|
21
|
|
|
21
|
0
|
29
|
my $json = shift; |
13
|
21
|
|
|
|
|
25
|
my $data = eval { JSON::PP->new->utf8->relaxed->decode($json); }; |
|
21
|
|
|
|
|
93
|
|
14
|
21
|
50
|
|
|
|
10220
|
if ($@) { |
15
|
0
|
|
|
|
|
0
|
my $msg = reverse $@; |
16
|
0
|
|
|
|
|
0
|
$msg =~ s/.+? ta //sm; |
17
|
0
|
|
|
|
|
0
|
$msg = "JSON error: " . scalar reverse($msg); |
18
|
0
|
0
|
|
|
|
0
|
$msg .= " in " . shift if @_; |
19
|
0
|
|
|
|
|
0
|
die "$msg\n"; |
20
|
|
|
|
|
|
|
} |
21
|
21
|
|
|
|
|
54
|
return $data; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub encode_json { |
25
|
18
|
|
|
18
|
0
|
108
|
JSON::PP->new->utf8->pretty->encode($_[0]); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
__END__ |