File Coverage

blib/lib/Mojo/JSON_XS.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod n/a
total 32 32 100.0


line stmt bran cond sub pod time code
1             package Mojo::JSON_XS;
2 2     2   115053 use strict;
  2         4  
  2         55  
3 2     2   10 use warnings;
  2         4  
  2         80  
4              
5             our $VERSION = 1.003;
6             # From groups.google.com/forum/#!msg/mojolicious/a4jDdz-gTH0/Exs0-E1NgQEJ
7              
8 2     2   765 use Cpanel::JSON::XS;
  2         3192  
  2         117  
9 2     2   800 use Mojo::JSON;
  2         110725  
  2         98  
10 2     2   16 use Mojo::Util 'monkey_patch';
  2         6  
  2         446  
11              
12             my $Binary = Cpanel::JSON::XS->new->utf8(1)->canonical(1)
13             ->allow_blessed(1)->allow_nonref(1)->allow_unknown(1)->convert_blessed(1);
14             my $Text = Cpanel::JSON::XS->new->utf8(0)->canonical(1)
15             ->allow_blessed(1)->allow_nonref(1)->allow_unknown(1)->convert_blessed(1);
16              
17 59     59   20039 monkey_patch 'Mojo::JSON', encode_json => sub { $Binary->encode(shift) };
18 69     69   39745 monkey_patch 'Mojo::JSON', decode_json => sub { $Binary->decode(shift) };
19              
20 2     2   13 monkey_patch 'Mojo::JSON', to_json => sub { $Text->encode(shift) };
21 3     3   446 monkey_patch 'Mojo::JSON', from_json => sub { $Text->decode(shift) };
22              
23 11     11   1956 monkey_patch 'Mojo::JSON', true => sub () { Cpanel::JSON::XS::true() };
24 9     9   1521 monkey_patch 'Mojo::JSON', false => sub () { Cpanel::JSON::XS::false() };
25              
26             1;
27             __END__