File Coverage

blib/lib/IPC/Manager/Serializer/JSON.pm
Criterion Covered Total %
statement 21 26 80.7
branch 1 2 50.0
condition 3 9 33.3
subroutine 6 6 100.0
pod 2 2 100.0
total 33 45 73.3


line stmt bran cond sub pod time code
1             package IPC::Manager::Serializer::JSON;
2 2     2   698612 use strict;
  2         5  
  2         88  
3 2     2   11 use warnings;
  2         7  
  2         130  
4              
5             our $VERSION = '0.000005';
6              
7 2     2   10 use parent 'IPC::Manager::Serializer';
  2         8  
  2         12  
8              
9             BEGIN {
10 2     2   293 local $@;
11 2         6 my $class;
12 2   33     12 $class //= eval { require Cpanel::JSON::XS; 'Cpanel::JSON::XS' };
  2         2163  
  2         7888  
13 2   33     8 $class //= eval { require JSON::XS; 'JSON::XS' };
  0         0  
  0         0  
14 2   33     5 $class //= eval { require JSON::PP; 'JSON::PP' };
  0         0  
  0         0  
15              
16 2 50       5 die "Could not find 'Cpanel::JSON::XS', 'JSON::XS', or 'JSON::PP'" unless $class;
17              
18 2         14 my $json = $class->new->ascii(1)->convert_blessed(1)->allow_nonref(1);
19              
20 2         201 *JSON = sub() { $json };
  0         0  
21             }
22              
23 52     52 1 631 sub serialize { JSON()->encode($_[1]) }
24 48     48 1 798 sub deserialize { JSON()->decode($_[1]) }
25              
26             1;
27              
28             __END__