line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAML::Tiny::LikeJSON; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
120772
|
$YAML::Tiny::LikeJSON::VERSION = '0.0011'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Use YAML::Tiny like JSON |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1152
|
use YAML::Tiny; |
|
1
|
|
|
|
|
6648
|
|
|
1
|
|
|
|
|
81
|
|
12
|
1
|
|
|
1
|
|
11
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
248
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
1
|
15
|
sub new { return bless {}, shift } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub decode { |
17
|
2
|
|
|
2
|
1
|
65
|
my $self = shift; |
18
|
2
|
|
|
|
|
16
|
my $YAML = YAML::Tiny->read_string( $_[0] ); |
19
|
2
|
100
|
|
|
|
786
|
if ( ( my $size = @$YAML ) > 1 ) { |
20
|
1
|
|
|
|
|
32
|
carp "Decoded more than 1 document (actually $size, but only returning the first)" |
21
|
|
|
|
|
|
|
} |
22
|
2
|
|
|
|
|
675
|
return $YAML->[0]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub encode { |
26
|
1
|
|
|
1
|
1
|
25720
|
my $self = shift; |
27
|
1
|
|
|
|
|
11
|
my $YAML = YAML::Tiny->new( $_[0] ); |
28
|
1
|
|
|
|
|
11
|
my $content = $YAML->write_string; |
29
|
1
|
|
|
|
|
240
|
$content =~ s/\A\s*---\s*\n+//sm; |
30
|
1
|
|
|
|
|
10
|
return $content; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |