blib/lib/Catmandu/Fix/from_json.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 96.5% 28 / 29 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Catmandu/Fix/SimpleGetValue.pm ↑ Summary blib/lib/Catmandu/Fix/remove_field.pm »
1 package Catmandu::Fix::from_json;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.0201_02';
6  
7 1 ▶use Cpanel::JSON::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 has path => (fix_arg => 1);
13  
14 1 with 'Catmandu::Fix::SimpleGetValue';
15  
16 sub emit_value {
17 2 ▶ my ($self, $var, $fixer) = @_;
Subroutine emit_value: called CC=1 SCAR=0.0
Pod undocumented
18 2 my $json_var = $fixer->capture(
19 Cpanel::JSON::XS->new->utf8(0)->pretty(0)->allow_nonref(1));
20  
21 2 "if (is_string(${var})) {"
22 . "${var} = ${json_var}->decode(${var});" . "}";
23 }
24  
25 1 1;
26  
27 __END__
28  
29 =pod
30  
31 =head1 NAME
32  
33 Catmandu::Fix::from_json - replace a json field with the parsed value
34  
35 =head1 SYNOPSIS
36  
37 from_json(my.field)
38  
39 =head1 SEE ALSO
40  
41 L<Catmandu::Fix>
42  
43 =cut
44  
45  
« blib/lib/Catmandu/Fix/SimpleGetValue.pm ↑ Summary blib/lib/Catmandu/Fix/remove_field.pm »