| 1 | package Error::Pure::Output::JSON; | ||||||||||
| 2 | |||||||||||
| 3 | # Pragmas. | ||||||||||
| 4 | 3 | ▶ | use base qw(Exporter); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | # Modules. | ||||||||||
| 9 | 3 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | # Constants. | ||||||||||
| 13 | 3 | Readonly::Array our @EXPORT_OK => qw(err_json); | |||||||||
| 14 | |||||||||||
| 15 | # Global variables. | ||||||||||
| 16 | 3 | our $PRETTY = 0; | |||||||||
| 17 | |||||||||||
| 18 | # Version. | ||||||||||
| 19 | 3 | our $VERSION = 0.10; | |||||||||
| 20 | |||||||||||
| 21 | # JSON print of backtrace. | ||||||||||
| 22 | sub err_json { | ||||||||||
| 23 | 2 | ▶ | my @errors = @_; | ||||||||
|
Subroutine
err_json: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 24 | 2 | my $ret_json; | |||||||||
| 25 | 2 | my $json = JSON->new; | |||||||||
| 26 | 2 | ▶ | if ($PRETTY) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 1 | $ret_json = $json->pretty->encode(@errors); | |||||||||
| 28 | } else { | ||||||||||
| 29 | 1 | $ret_json = $json->encode(@errors); | |||||||||
| 30 | } | ||||||||||
| 31 | 2 | return $ret_json; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 3 | 1; | |||||||||
| 35 | |||||||||||
| 36 | __END__ | ||||||||||