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   104672 use strict;
  2         6  
  2         61  
3 2     2   11 use warnings;
  2         4  
  2         88  
4              
5             our $VERSION = 1.002;
6             # From groups.google.com/forum/#!msg/mojolicious/a4jDdz-gTH0/Exs0-E1NgQEJ
7              
8 2     2   1508 use Cpanel::JSON::XS;
  2         8797  
  2         139  
9 2     2   800 use Mojo::JSON;
  2         98030  
  2         134  
10 2     2   24 use Mojo::Util 'monkey_patch';
  2         5  
  2         615  
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   32826 monkey_patch 'Mojo::JSON', encode_json => sub { $Binary->encode(shift) };
18 69     69   51676 monkey_patch 'Mojo::JSON', decode_json => sub { $Binary->decode(shift) };
19              
20 2     2   21 monkey_patch 'Mojo::JSON', to_json => sub { $Text->encode(shift) };
21 3     3   458 monkey_patch 'Mojo::JSON', from_json => sub { $Text->decode(shift) };
22              
23 11     11   3223 monkey_patch 'Mojo::JSON', true => sub () { Cpanel::JSON::XS::true() };
24 9     9   2097 monkey_patch 'Mojo::JSON', false => sub () { Cpanel::JSON::XS::false() };
25              
26             1;
27             __END__