line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON5; |
2
|
11
|
|
|
11
|
|
192252
|
use 5.008001; |
|
11
|
|
|
|
|
28
|
|
3
|
11
|
|
|
11
|
|
42
|
use strict; |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
205
|
|
4
|
11
|
|
|
11
|
|
41
|
use warnings; |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
415
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
35
|
use Exporter 'import'; |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
444
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/decode_json5/; |
10
|
|
|
|
|
|
|
|
11
|
11
|
|
|
11
|
|
5793
|
use JSON::PP; |
|
11
|
|
|
|
|
106055
|
|
|
11
|
|
|
|
|
722
|
|
12
|
11
|
|
|
11
|
|
3843
|
use JSON5::Parser; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
1915
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $JSON5; # cache |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
33
|
1
|
1
|
30
|
sub decode_json5 { ($JSON5 ||= JSON5->new->utf8)->decode(@_) } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
5
|
|
|
5
|
1
|
39
|
my $class = shift; |
20
|
5
|
|
|
|
|
40
|
return bless { |
21
|
|
|
|
|
|
|
parser => JSON5::Parser->new, |
22
|
|
|
|
|
|
|
} => $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub true; |
26
|
|
|
|
|
|
|
sub false; |
27
|
|
|
|
|
|
|
*true = \&JSON::PP::true; |
28
|
|
|
|
|
|
|
*false = \&JSON::PP::false; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# define accessors |
31
|
|
|
|
|
|
|
BEGIN { |
32
|
11
|
|
|
11
|
|
24
|
for my $attr (qw/utf8 allow_nonref max_size inflate_boolean inflate_nan inflate_null inflate_infinity/) { |
33
|
|
|
|
|
|
|
my $attr_accessor = sub { |
34
|
12
|
|
|
12
|
|
2846
|
my $self = shift; |
35
|
12
|
|
|
|
|
67
|
$self->{parser}->$attr(@_); |
36
|
12
|
|
|
|
|
47
|
return $self; |
37
|
77
|
|
|
|
|
139
|
}; |
38
|
|
|
|
|
|
|
my $attr_getter = sub { |
39
|
7
|
|
|
7
|
|
2380
|
my $self = shift; |
40
|
7
|
|
|
|
|
16
|
my $get_attr = "get_$attr"; |
41
|
7
|
|
|
|
|
26
|
return $self->{parser}->$get_attr; |
42
|
77
|
|
|
|
|
132
|
}; |
43
|
|
|
|
|
|
|
|
44
|
11
|
|
|
11
|
|
49
|
no strict qw/refs/; |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
462
|
|
45
|
77
|
|
|
|
|
53
|
*{"$attr"} = $attr_accessor; |
|
77
|
|
|
|
|
174
|
|
46
|
77
|
|
|
|
|
62
|
*{"get_$attr"} = $attr_getter; |
|
77
|
|
|
|
|
714
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub decode { |
51
|
5
|
|
|
5
|
1
|
1454
|
my $self = shift; |
52
|
5
|
|
|
|
|
18
|
return $self->{parser}->parse(@_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
__END__ |