line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Syck; |
2
|
14
|
|
|
14
|
|
5390
|
use strict; |
|
14
|
|
|
|
|
17
|
|
|
14
|
|
|
|
|
390
|
|
3
|
14
|
|
|
14
|
|
45
|
use vars qw( $VERSION @EXPORT_OK @ISA ); |
|
14
|
|
|
|
|
12
|
|
|
14
|
|
|
|
|
593
|
|
4
|
14
|
|
|
14
|
|
46
|
use Exporter; |
|
14
|
|
|
|
|
13
|
|
|
14
|
|
|
|
|
365
|
|
5
|
14
|
|
|
14
|
|
1599
|
use YAML::Syck (); |
|
14
|
|
|
|
|
17
|
|
|
14
|
|
|
|
|
749
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
14
|
|
|
14
|
|
38
|
$VERSION = '1.30_01'; |
9
|
14
|
|
|
|
|
39
|
@EXPORT_OK = qw( Load Dump LoadFile DumpFile DumpInto ); |
10
|
14
|
|
|
|
|
93
|
@ISA = 'Exporter'; |
11
|
14
|
|
|
|
|
31
|
*Load = \&YAML::Syck::LoadJSON; |
12
|
14
|
|
|
|
|
4213
|
*Dump = \&YAML::Syck::DumpJSON; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub DumpFile { |
16
|
0
|
|
|
0
|
0
|
0
|
my $file = shift; |
17
|
0
|
0
|
|
|
|
0
|
if ( YAML::Syck::_is_glob($file) ) { |
18
|
0
|
|
|
|
|
0
|
my $err = YAML::Syck::DumpJSONFile( $_[0], $file ); |
19
|
0
|
0
|
|
|
|
0
|
if ($err) { |
20
|
0
|
|
|
|
|
0
|
$! = 0 + $err; |
21
|
0
|
|
|
|
|
0
|
die "Error writing to filehandle $file: $!\n"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
0
|
0
|
|
|
|
0
|
open( my $fh, '>', $file ) or die "Cannot write to $file: $!"; |
26
|
0
|
|
|
|
|
0
|
my $err = YAML::Syck::DumpJSONFile( $_[0], $fh ); |
27
|
0
|
0
|
|
|
|
0
|
if ($err) { |
28
|
0
|
|
|
|
|
0
|
$! = 0 + $err; |
29
|
0
|
|
|
|
|
0
|
die "Error writing to file $file: $!\n"; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
0
|
|
|
|
0
|
close $fh |
32
|
|
|
|
|
|
|
or die "Error writing to file $file: $!\n"; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
0
|
return 1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub LoadFile { |
38
|
10
|
|
|
10
|
0
|
6489
|
my $file = shift; |
39
|
10
|
100
|
|
|
|
19
|
if ( YAML::Syck::_is_glob($file) ) { |
40
|
|
|
|
|
|
|
YAML::Syck::LoadJSON( |
41
|
8
|
|
|
|
|
4
|
do { local $/; <$file> } |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
376
|
|
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
2
|
100
|
66
|
|
|
32
|
if ( !-e $file || -z $file ) { |
46
|
1
|
|
|
|
|
10
|
die("'$file' is non-existent or empty"); |
47
|
|
|
|
|
|
|
} |
48
|
1
|
50
|
|
|
|
19
|
open( my $fh, '<', $file ) or die "Cannot read from $file: $!"; |
49
|
|
|
|
|
|
|
YAML::Syck::LoadJSON( |
50
|
1
|
|
|
|
|
1
|
do { local $/; <$fh> } |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
54
|
|
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub DumpInto { |
56
|
7
|
|
|
7
|
0
|
46
|
my $bufref = shift; |
57
|
7
|
50
|
|
|
|
18
|
( ref $bufref ) or die "DumpInto not given reference to output buffer\n"; |
58
|
7
|
|
|
|
|
291
|
YAML::Syck::DumpJSONInto( $_[0], $bufref ); |
59
|
7
|
|
|
|
|
15
|
1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$JSON::Syck::ImplicitTyping = 1; |
63
|
|
|
|
|
|
|
$JSON::Syck::MaxDepth = 512; |
64
|
|
|
|
|
|
|
$JSON::Syck::Headless = 1; |
65
|
|
|
|
|
|
|
$JSON::Syck::ImplicitUnicode = 0; |
66
|
|
|
|
|
|
|
$JSON::Syck::SingleQuote = 0; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |