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