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   113065 use strict;
  2         4  
  2         58  
3 2     2   10 use warnings;
  2         5  
  2         93  
4              
5             our $VERSION = 1.001;
6             # From groups.google.com/forum/#!msg/mojolicious/a4jDdz-gTH0/Exs0-E1NgQEJ
7              
8 2     2   1554 use Cpanel::JSON::XS;
  2         6178  
  2         119  
9 2     2   743 use Mojo::JSON;
  2         98349  
  2         117  
10 2     2   25 use Mojo::Util 'monkey_patch';
  2         6  
  2         491  
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   20573 monkey_patch 'Mojo::JSON', encode_json => sub { $Binary->encode(shift) };
18 69     69   43649 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   450 monkey_patch 'Mojo::JSON', from_json => sub { $Text->decode(shift) };
22              
23 11     11   2036 monkey_patch 'Mojo::JSON', true => sub () { Cpanel::JSON::XS::true() };
24 9     9   1769 monkey_patch 'Mojo::JSON', false => sub () { Cpanel::JSON::XS::false() };
25              
26             1;
27             __END__