| 1 | package Carton::Util; | ||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 0 | ▶ | sub load_json { | ||||||||
|
Subroutine
load_json: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 6 | 0 | my $file = shift; | |||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | open my $fh, "<", $file or die "$file: $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 9 | 0 | from_json(join '', <$fh>); | |||||||||
| 10 | } | ||||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub dump_json { | ||||||||
|
Subroutine
dump_json: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 13 | 0 | my($data, $file) = @_; | |||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | open my $fh, ">", $file or die "$file: $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | binmode $fh; | |||||||||
| 17 | 0 | print $fh to_json($data); | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub from_json { | ||||||||
|
Subroutine
from_json: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 21 | 0 | require JSON; | |||||||||
| 22 | 0 | JSON::decode_json(@_); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub to_json { | ||||||||
|
Subroutine
to_json: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 26 | 0 | my($data) = @_; | |||||||||
| 27 | 0 | require JSON; | |||||||||
| 28 | 0 | JSON->new->utf8->pretty->canonical->encode($data); | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 3 | 1; | |||||||||