package Data::Format::Pretty::JSON;
our $DATE = '2016-03-11'; # DATE
our $VERSION = '0.12'; # VERSION
use 5.010001;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_
= qw(format_pretty);
sub content_type { "application/json" }
sub format_pretty {
my ($data, $opts) = @_;
$opts //= {};
state $json;
my $interactive = (-t STDOUT);
my $pretty =
equire JSON::Color;
JSON::Color::encode_json($data, {pretty=>$pretty, linum=>$linum})."\n";
} else {
if (!$json) {
require JSON::MaybeXS;
$json = JSON::Mayb
actJSON;
use 5.010;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(format_pretty);
our $VERSION = '0.12'; # VERSION
sub content_type { "application/json"
ata, $opts) = @_;
state $json;
$opts //= {};
if ($opts->{color} // $ENV{COLOR} // (-t STDOUT)) {
require JSON::Color;
JSON::Color::encode_json($data, {pretty=>0, linum=>0
});
} else {
if (!$json) {
require JSON::MaybeXS;
$json = JSON::MaybeXS->new->utf8->allow_nonref;
}
$json->encode($data);
}
}
1;
# ABSTRACT: Pr