line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
76637
|
use 5.008; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
169
|
|
2
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
136
|
|
3
|
4
|
|
|
4
|
|
26
|
use warnings; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
165
|
|
4
|
4
|
|
|
4
|
|
4334
|
use if $] < 5.010, 'UNIVERSAL::DOES'; |
|
4
|
|
|
|
|
39
|
|
|
4
|
|
|
|
|
79
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
package JSON::MultiValueOrdered; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
10
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
410
|
use base qw(JSON::Tiny::Subclassable); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2034
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
2720
|
use Tie::Hash::MultiValueOrdered (); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
1505
|
|
15
|
|
|
|
|
|
|
|
16
|
6
|
|
|
6
|
|
41
|
sub _new_hash { tie my %h, 'Tie::Hash::MultiValueOrdered'; return \%h } |
|
6
|
|
|
|
|
17
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _encode_object { |
19
|
4
|
|
|
4
|
|
6
|
my $self = shift; |
20
|
4
|
|
|
|
|
6
|
my $object = shift; |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
4
|
my $indent; |
23
|
4
|
100
|
|
|
|
18
|
if (exists $self->{_indent}) { |
24
|
3
|
|
|
|
|
4
|
$indent = $self->{_indent}; |
25
|
3
|
|
|
|
|
5
|
$self->{_indent} .= "\t"; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
6
|
my @pairs; |
29
|
4
|
100
|
|
|
|
15
|
my $space = defined $indent ? q( ) : q(); |
30
|
4
|
|
|
|
|
8
|
my $tied = tied(%$object); |
31
|
4
|
50
|
33
|
|
|
39
|
if ($tied and $tied->DOES('Tie::Hash::MultiValueOrdered')) { |
32
|
4
|
|
|
|
|
14
|
my @list = $tied->pairs; |
33
|
4
|
|
|
|
|
16
|
for (my $i = 0; $i < @list; $i+=2) { |
34
|
14
|
|
|
|
|
47
|
push @pairs, sprintf( |
35
|
|
|
|
|
|
|
'%s:%s%s', |
36
|
|
|
|
|
|
|
$self->_encode_string($list[$i]), |
37
|
|
|
|
|
|
|
$space, |
38
|
|
|
|
|
|
|
$self->_encode_values($list[$i + 1]), |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
0
|
|
|
|
|
0
|
while (my ($k, $v) = each %$object) { |
44
|
0
|
|
|
|
|
0
|
push @pairs, sprintf( |
45
|
|
|
|
|
|
|
'%s:%s%s', |
46
|
|
|
|
|
|
|
$self->_encode_string($k), |
47
|
|
|
|
|
|
|
$space, |
48
|
|
|
|
|
|
|
$self->_encode_values($v), |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
4
|
100
|
|
|
|
13
|
if (defined $indent) |
54
|
|
|
|
|
|
|
{ |
55
|
3
|
|
|
|
|
11
|
$self->{_indent} =~ s/^.//; |
56
|
3
|
100
|
|
|
|
19
|
return "{}" unless @pairs; |
57
|
2
|
|
|
|
|
28
|
return "\{\n$indent\t" . join(",\n$indent\t", @pairs) . "\n$indent\}"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else |
60
|
|
|
|
|
|
|
{ |
61
|
1
|
|
|
|
|
11
|
return '{' . join(',', @pairs) . '}'; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__PACKAGE__->import('j'); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |