package App::yajg::Output::Json;
use 5.014000;
use strict;
use warnings;
use utf8;
use parent qw(App::yajg::Output);
use App::yajg;
use JSON qw();
sub lang {'js'} # lang for highli
my $self = shift;
local $SIG{__WARN__} = \&App::yajg::warn_without_line;
my $json = eval {
JSON
->new
->pretty(not $self->minimal)
->canonical($self->so
rt_keys // 0)
->allow_nonref
->encode($self->data)
};
if ($@) {
warn $@;
return '';
}
return $json;
}
1;
;
use JSON qw();
sub boolean_to_scalar_ref {
return unless JSON::is_bool($_[0]);
$_[0] = $_[0]
? \(my $t = 1)
: \(my $f = 0);
}
sub boolean_to_int {
return unless JSON::is_b
ool($_[0]);
$_[0] = int(!!$_[0]);
}
sub boolean_to_str {
return unless JSON::is_bool($_[0]);
$_[0] = $_[0]
? 'true'
: 'false';
}
sub _decode_uri ($) {
local $_ = shift //
s;
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
use utf8;
use Data::Dumper;
use JSON qw();
our $VERSION = '0.20';
sub MAX_RECURSION () {300}
{
my $inc = caller() ? $INC{ __PAC
read_next_json_file () {
local $/;
local $SIG{__WARN__} = \&warn_without_line;
while (<>) {
utf8::encode($_) if utf8::is_utf8($_);
$_ = eval { JSON::decode_json($_) };
hift;
state $supported = {
'ddp' => 'App::yajg::Output::DDP',
'json' => 'App::yajg::Output::Json',
'perl' => 'App::yajg::Output::Perl',
'yaml' => 'App::yajg::Outpu