File Coverage

blib/lib/Data/Serializer/JSON/MaybeXS.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition 2 3 66.6
subroutine 9 9 100.0
pod 2 3 66.6
total 36 38 94.7


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