File Coverage

blib/lib/App/yajg/Output/Json.pm
Criterion Covered Total %
statement 27 30 90.0
branch 1 2 50.0
condition n/a
subroutine 9 10 90.0
pod 0 3 0.0
total 37 45 82.2


line stmt bran cond sub pod time code
1             package App::yajg::Output::Json;
2              
3 1     1   954 use 5.014000;
  1         4  
4 1     1   4 use strict;
  1         1  
  1         15  
5 1     1   2 use warnings;
  1         1  
  1         16  
6 1     1   3 use utf8;
  1         1  
  1         5  
7              
8 1     1   395 use parent qw(App::yajg::Output);
  1         232  
  1         4  
9              
10 1     1   74 use App::yajg;
  1         2  
  1         21  
11 1     1   4 use JSON qw();
  1         2  
  1         148  
12              
13 0     0 0 0 sub lang {'js'} # lang for highlight
14 1     1 0 5 sub need_change_depth {1} # need to change max depth via Data::Dumper
15              
16             sub as_string {
17 3     3 0 5 my $self = shift;
18 3         10 local $SIG{__WARN__} = \&App::yajg::warn_without_line;
19 3         4 my $json = eval {
20 3         19 JSON
21             ->new
22             ->pretty(int not $self->minimal)
23             ->allow_nonref
24             ->canonical
25             ->encode($self->data)
26             };
27 3 50       55 if ($@) {
28 0         0 warn $@;
29 0         0 return '';
30             }
31 3         12 return $json;
32             }
33              
34             1;