blib/lib/Code/TidyAll/Plugin/JSON.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 2 SCAR 11.5
CC
2
Cov
0%
transform_source
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.1
1 package Code::TidyAll::Plugin::JSON;
2  
3 use strict;
4 use warnings;
5  
6 use JSON::MaybeXS ();
7 use Specio::Library::Builtins;
8  
9 use Moo;
10  
11 our $VERSION = '0.85';
12  
13 extends 'Code::TidyAll::Plugin';
14  
15 has ascii => (
16 is => 'ro',
17 isa => t('Bool'),
18 default => 0,
19 );
20  
21 sub transform_source {
22 my $self = shift;
23 my $source = shift;
24  
25 my $json = JSON::MaybeXS->new(
26 canonical => 1,
27 pretty => 1,
28 relaxed => 1,
29 utf8 => 1,
30 );
31  
32 $json = $json->ascii if $self->ascii;
33  
34 return $json->encode( $json->decode($source) );
35 }
36  
37 1;
38  
39 # ABSTRACT: Use the JSON::MaybeXS module to tidy JSON documents with tidyall
40  
41 __END__