line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JavaScript::Dumper; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
47505
|
use 5.005; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
79
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
66
|
|
5
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
82
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
2
|
|
|
2
|
|
10
|
use base "JSON::PP"; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
3218
|
|
8
|
2
|
|
|
2
|
|
42992
|
use overload; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
79
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
30
|
|
11
|
2
|
|
|
2
|
|
12
|
use B (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
40
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
2506
|
use Class::C3; |
|
2
|
|
|
|
|
9254
|
|
|
2
|
|
|
|
|
14
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$JavaScript::Dumper::VERSION = '0.011'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@JavaScript::Dumper::EXPORT = qw(js_dumper); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $JSON; # cache |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub js_dumper ($) { # encode |
22
|
1
|
|
33
|
1
|
1
|
30
|
($JSON ||= __PACKAGE__->new)->encode(@_); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub value_to_json { |
26
|
9
|
|
|
9
|
0
|
381
|
my ($self, $value) = @_; |
27
|
9
|
|
|
|
|
12
|
my $type = ref($value); |
28
|
9
|
100
|
66
|
|
|
57
|
if (!defined $value) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
return "null"; |
30
|
|
|
|
|
|
|
} elsif($type eq "SCALAR") { |
31
|
3
|
100
|
|
|
|
12
|
return "true" if($$value eq "1"); |
32
|
1
|
50
|
|
|
|
3
|
return "false" if($$value eq "0"); |
33
|
1
|
|
|
|
|
4
|
return $$value; |
34
|
|
|
|
|
|
|
} elsif(!$type && $value =~ /^\d+$/ ) { |
35
|
3
|
100
|
|
|
|
13
|
return $value if( int($value) eq $value); |
36
|
|
|
|
|
|
|
} |
37
|
3
|
|
|
|
|
14
|
$self->next::method($value); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |