line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Serializer::JSON::MaybeXS; |
2
|
|
|
|
|
|
|
$Data::Serializer::JSON::MaybeXS::VERSION = '0.01'; |
3
|
1
|
|
|
1
|
|
908
|
BEGIN { @Data::Serializer::JSON::MaybeXS::ISA = qw(Data::Serializer) } |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# This code was pretty much stolen and modified from: |
6
|
|
|
|
|
|
|
# Data::Serializer::JSON. |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
9
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
10
|
1
|
|
|
1
|
|
812
|
use JSON::MaybeXS qw(); |
|
1
|
|
|
|
|
1582
|
|
|
1
|
|
|
|
|
35
|
|
11
|
1
|
|
|
1
|
|
6
|
use vars qw(@ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
297
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub json { |
14
|
2
|
|
|
2
|
0
|
4
|
my ($self) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$self->{json} ||= JSON::MaybeXS->new( |
17
|
2
|
|
66
|
|
|
11
|
%{ $self->{options} }, |
|
1
|
|
|
|
|
8
|
|
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
48
|
return $self->{json}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub serialize { |
24
|
1
|
|
|
1
|
1
|
38
|
my ($self, $data) = @_; |
25
|
1
|
|
|
|
|
3
|
return $self->json->encode( $data ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub deserialize { |
29
|
1
|
|
|
1
|
1
|
16
|
my ($self, $json) = @_; |
30
|
1
|
|
|
|
|
3
|
return $self->json->decode( $json ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
__END__ |