line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Syck; |
2
|
14
|
|
|
14
|
|
11337
|
use strict; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
611
|
|
3
|
14
|
|
|
14
|
|
73
|
use vars qw( $VERSION @EXPORT_OK @ISA ); |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
1014
|
|
4
|
14
|
|
|
14
|
|
73
|
use Exporter; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
502
|
|
5
|
14
|
|
|
14
|
|
7414
|
use YAML::Syck (); |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
988
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
14
|
|
|
14
|
|
31
|
$VERSION = '1.28_01'; |
9
|
14
|
|
|
|
|
48
|
@EXPORT_OK = qw( Load Dump LoadFile DumpFile DumpInto ); |
10
|
14
|
|
|
|
|
213
|
@ISA = 'Exporter'; |
11
|
14
|
|
|
|
|
63
|
*Load = \&YAML::Syck::LoadJSON; |
12
|
14
|
|
|
|
|
9119
|
*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
|
11045
|
my $file = shift; |
39
|
10
|
100
|
|
|
|
43
|
if ( YAML::Syck::_is_glob($file) ) { |
40
|
|
|
|
|
|
|
YAML::Syck::LoadJSON( |
41
|
8
|
|
|
|
|
11
|
do { local $/; <$file> } |
|
8
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
739
|
|
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
2
|
100
|
66
|
|
|
51
|
if ( !-e $file || -z $file ) { |
46
|
1
|
|
|
|
|
11
|
die("'$file' is non-existent or empty"); |
47
|
|
|
|
|
|
|
} |
48
|
1
|
50
|
|
|
|
33
|
open( my $fh, '<', $file ) or die "Cannot read from $file: $!"; |
49
|
|
|
|
|
|
|
YAML::Syck::LoadJSON( |
50
|
1
|
|
|
|
|
2
|
do { local $/; <$fh> } |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
94
|
|
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub DumpInto { |
56
|
7
|
|
|
7
|
0
|
61
|
my $bufref = shift; |
57
|
7
|
50
|
|
|
|
18
|
( ref $bufref ) or die "DumpInto not given reference to output buffer\n"; |
58
|
7
|
|
|
|
|
543
|
YAML::Syck::DumpJSONInto( $_[0], $bufref ); |
59
|
7
|
|
|
|
|
20
|
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__ |