line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Serialize::Serializer::JSON::MaybeXS; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
#ABSTRACT: JSON::MaybeXS serializer for File::Serialize |
4
|
|
|
|
|
|
|
$File::Serialize::Serializer::JSON::MaybeXS::VERSION = '1.5.1'; |
5
|
5
|
|
|
5
|
|
4973
|
use strict; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
153
|
|
6
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
139
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
574
|
use Moo; |
|
5
|
|
|
|
|
8759
|
|
|
5
|
|
|
|
|
29
|
|
9
|
|
|
|
|
|
|
with 'File::Serialize::Serializer'; |
10
|
|
|
|
|
|
|
|
11
|
42
|
|
|
42
|
1
|
146
|
sub extensions { qw/ json js / }; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub serialize { |
14
|
|
|
|
|
|
|
my( $self, $data, $options ) = @_; |
15
|
|
|
|
|
|
|
JSON::MaybeXS->new(%$options)->encode( $data); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub deserialize { |
19
|
|
|
|
|
|
|
my( $self, $data, $options ) = @_; |
20
|
|
|
|
|
|
|
JSON::MaybeXS->new(%$options)->decode( $data); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub groom_options { |
24
|
37
|
|
|
37
|
0
|
86
|
my( $self, $options ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
37
|
|
|
|
|
71
|
my %groomed; |
27
|
37
|
|
|
|
|
79
|
for my $k( qw/ pretty canonical allow_nonref / ) { |
28
|
111
|
100
|
|
|
|
378
|
$groomed{$k} = $options->{$k} if defined $options->{$k}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
37
|
|
|
|
|
139
|
return \%groomed; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |