line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
68478
|
use 5.008; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
159
|
|
2
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
126
|
|
3
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
163
|
|
4
|
4
|
|
|
4
|
|
3796
|
use if $] < 5.010, 'UNIVERSAL::DOES'; |
|
4
|
|
|
|
|
35
|
|
|
4
|
|
|
|
|
21
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
package JSON::MultiValueOrdered; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
10
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
267
|
use base qw(JSON::Tiny::Subclassable); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2183
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
2383
|
use Tie::Hash::MultiValueOrdered (); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
1360
|
|
15
|
|
|
|
|
|
|
|
16
|
6
|
|
|
6
|
|
45
|
sub _new_hash { tie my %h, 'Tie::Hash::MultiValueOrdered'; return \%h } |
|
6
|
|
|
|
|
20
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _encode_object { |
19
|
4
|
|
|
4
|
|
6
|
my $self = shift; |
20
|
4
|
|
|
|
|
7
|
my $object = shift; |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
5
|
my $indent; |
23
|
4
|
100
|
|
|
|
19
|
if (exists $self->{_indent}) { |
24
|
3
|
|
|
|
|
4
|
$indent = $self->{_indent}; |
25
|
3
|
|
|
|
|
6
|
$self->{_indent} .= "\t"; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
5
|
my @pairs; |
29
|
4
|
100
|
|
|
|
17
|
my $space = defined $indent ? q( ) : q(); |
30
|
4
|
|
|
|
|
6
|
my $tied = tied(%$object); |
31
|
4
|
50
|
33
|
|
|
41
|
if ($tied and $tied->DOES('Tie::Hash::MultiValueOrdered')) { |
32
|
4
|
|
|
|
|
18
|
my @list = $tied->pairs; |
33
|
4
|
|
|
|
|
43
|
for (my $i = 0; $i < @list; $i+=2) { |
34
|
14
|
|
|
|
|
50
|
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
|
|
|
|
14
|
if (defined $indent) |
54
|
|
|
|
|
|
|
{ |
55
|
3
|
|
|
|
|
10
|
$self->{_indent} =~ s/^.//; |
56
|
3
|
100
|
|
|
|
18
|
return "{}" unless @pairs; |
57
|
2
|
|
|
|
|
28
|
return "\{\n$indent\t" . join(",\n$indent\t", @pairs) . "\n$indent\}"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else |
60
|
|
|
|
|
|
|
{ |
61
|
1
|
|
|
|
|
14
|
return '{' . join(',', @pairs) . '}'; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__PACKAGE__->import('j'); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |