package JSON::Slurper;
use strict;
use warnings;
use Carp ();
use Exporter::Shiny qw(slurp_json spurt_json);
use File::Basename ();
use File::Slurper ();
use Scalar::Util ();
our $VERSION = '0
=> [qw(slurp_json spurt_json)],
std_auto => [qw(-auto_ext slurp_json spurt_json)],
slurp_auto => [qw(-auto_ext slurp_json)],
spurt_auto => [qw(-auto_ext spurt_json)],
);
my $DEFAULT
ENV{JSON_SLURPER_NO_JSON_XS} ? do { require JSON::PP; 'JSON::PP' }
: eval { require Cpanel::JSON::XS; Cpanel::JSON::XS->VERSION('4.09'); 1 } ? 'Cpanel::JSON::XS'
: do { require JSON::P
package Data::Clean::JSON;
our $DATE = '2019-09-11'; # DATE
our $VERSION = '0.392'; # VERSION
use 5.010001;
use strict;
use warnings;
use parent qw(Data::Clean);
use Exporter qw(import);
our @EXPO
clean_json_in_place
clone_and_clean_json
);
sub new {
my ($class, %opts) = @_;
# from FromJSON
$opts{"JSON::PP::Boolean"} //= ['on
e_or_zero'];
$opts{"JSON::XS::Boolean"} //= ['one_or_zero']; # this doesn't exist though
$opts{"Cpanel::JSON::XS::Boolean"} //= ['one_or_zero']; # this doesn't exist though
$opts{DateTime
package Catmandu::Fix::get_json;
our $VERSION = '0.51';
use Catmandu::Sane;
use Catmandu::Util;
use Moo;
use Catmandu::Fix::Has;
use Catmandu::Importer::getJSON;
with "Catmandu::Fix::Base";
has ur
{
$options{ $self->vars ? 'url' : 'from' } = $self->url;
}
Catmandu::Importer::getJSON->new(%options);
}
sub BUILD {
my ($self) = @_;
unless ( defined $self->path ) {
:get_json - get JSON data from an URL as fix function
=head1 SYNOPSIS
# fetches a hash or array
get_json("http://example.com/json")
# stores it in path.key
get_json("http://example.com/json", p
package WebService::ILS::JSON;
use Modern::Perl;
=encoding utf-8
=head1 NAME
WebService::ILS::JSON - WebService::ILS module for services with JSON API
=head1 DESCRIPTION
To be subclassed
See L<
WebService::ILS>
=cut
use Carp;
use HTTP::Request::Common;
use JSON qw(encode_json);
use URI;
use parent qw(WebService::ILS);
sub with_get_request {
my $self = shift;
my $callback = shift
n::GET( $uri );
my $response = $self->_request_with_auth($request);
return $self->process_json_response($response, $callback);
}
sub with_delete_request {
my $self = shift;
my $callba
package Mojo::JSON::MaybeXS;
use strict;
use warnings;
use Mojo::Util 'monkey_patch';
use JSON::MaybeXS 'JSON';
use Mojo::JSON ();
our $VERSION = '1.002';
my $BINARY = JSON::MaybeXS->new(utf8 => 1,
TEXT = JSON::MaybeXS->new(utf8 => 0, canonical => 1, allow_nonref => 1,
allow_unknown => 1, allow_blessed => 1, convert_blessed => 1);
my $TRUE = JSON->true;
my $FALSE = JSON->false;
if (JSON eq 'Cp
:JSON::XS') {
local $@;
if (eval { Cpanel::JSON::XS->VERSION('4.09'); 1 }) {
$BINARY->allow_dupkeys;
$TEXT->allow_dupkeys;
}
if (eval { Cpanel::JSON::XS->VERSION('3.0112'); 1 }) {
$BINARY->s
package Serge::Engine::Plugin::parse_chrome_json;
use parent Serge::Engine::Plugin::Base::Parser;
use strict;
use JSON -support_by_pp; # -support_by_pp is used to make Perl on Mac happy
use Serge::M
ail;
use Serge::Util qw(xml_escape_strref);
sub name {
return 'Chrome extension messages.json parser plugin';
}
sub init {
my $self = shift;
$self->SUPER::init(@_);
$self->{errors}
ject = $self->{data}->{email_subject} || ("[".$self->{parent}->{id}.']: Chrome Extension messages.json Parse Errors');
my $text;
foreach my $key (sort keys %{$self->{errors}}) {
my $p
package Serge::Engine::Plugin::parse_json_keyvalue;
use parent Serge::Engine::Plugin::Base::Parser;
use strict;
use JSON -support_by_pp; # -support_by_pp is used to make Perl on Mac happy
use Serge:
:Mail;
use Serge::Util qw(xml_escape_strref);
sub name {
return 'JSON Dictionary Parser Plugin';
}
sub init {
my $self = shift;
$self->SUPER::init(@_);
$self->{errors} = {};
$
;
}
my $email_subject = $self->{data}->{email_subject} || ("[".$self->{parent}->{id}.']: JSON Parse Errors');
my $text;
foreach my $key (sort keys %{$self->{errors}}) {
my $p
package MooX::TO_JSON;
use warnings;
use strict;
our $VERSION = '0.001';
$VERSION = eval $VERSION;
use Class::Method::Modifiers qw(install_modifier);
sub import {
my ($class) = @_;
my $target
= caller;
my @to_json;
install_modifier $target, 'fresh', 'TO_JSON', sub {
my $self = shift;
my @structure = ();
foreach my $rule (@to_json) {
if($rule->{omit_if_empty}) {
$rule->{mapped_field} => $value,
);
}
@structure = $self->modify_json(@structure) if $self->can('modify_json');
return +{ @structure };
};
my %types = (
str => 1,
num =>
ice::Firewall::PaloAlto::JSON;
$Device::Firewall::PaloAlto::JSON::VERSION = '0.1.9';
use strict;
use warnings;
use 5.010;
# We don't want all of the automatic imports
use JSON qw();
use Data::Struct
ODNAME
# ABSTRACT: JSON parent class for Device::Firewall::PaloAlto modules.
sub to_json {
my ($self, $filename) = @_;
my $output_fh;
my $structure = $self->pre_json_transform();
_fh;
}
$output_fh //= *STDOUT;
my $json_text = JSON->new->pretty->encode($structure);
print {$output_fh} $json_text;
}
sub pre_json_transform {
my $self = shift;
return un
kage Serge::Engine::Plugin::parse_json;
use parent Serge::Engine::Plugin::Base::Parser;
use parent Serge::Interface::PluginHost;
use strict;
use File::Path;
use JSON -support_by_pp; # -support_by_pp
Mac happy
use Serge::Mail;
use Serge::Util qw(xml_escape_strref);
sub name {
return 'Generic JSON tree parser plugin';
}
sub init {
my $self = shift;
$self->SUPER::init(@_);
$self-
;
}
my $email_subject = $self->{data}->{email_subject} || ("[".$self->{parent}->{id}.']: JSON Parse Errors');
my $text;
foreach my $key (sort keys %{$self->{errors}}) {
my $p
package JSON::ize;
use base Exporter;
use JSON::MaybeXS;
use YAML::Any qw/Dump Load LoadFile DumpFile/;
use Try::Tiny;
use strict;
use warnings;
our $JOBJ = JSON::MaybeXS->new();
our $YOBJ;
our $_las
t_out = "";
our @EXPORT = qw/jsonize jsonise J yamlize yamlise Y parsej pretty_json ugly_json/;
our $VERSION = "0.202";
sub jobj { $JOBJ }
sub jsonize (;$) {
my $inp = shift;
if (!defined $inp)
p) : jobj()->encode($inp);
}
else { # scalar: decode if looks like json or yaml, or slurp if filename
if (looks_like_json($inp)) {
return $_last_out = jobj()->decode($inp);
}
els
package Datahub::Factory::Exporter::JSON;
use Datahub::Factory::Sane;
our $VERSION = '1.77';
use Moo;
use Catmandu;
use namespace::clean;
with 'Datahub::Factory::Exporter';
sub _build_out {
m
JSON');
return $exporter;
}
sub add {
my ($self, $item) = @_;
$self->out->add($item);
}
1;
__END__
=encoding utf-8
=head1 NAME
Datahub::Factory::Exporter::JSON - Export items to JSON
tory;
my $exporter = Datahub::Factory->exporter('JSON')->new();
$exporter->add({'id' => 1});
=head1 DESCRIPTION
Convert records to JSON and send them to STDOUT. The records are
convert as-
package Datahub::Factory::Importer::JSON;
use Datahub::Factory::Sane;
our $VERSION = '1.77';
use Moo;
use Catmandu;
use namespace::clean;
with 'Datahub::Factory::Importer';
has file_name => (is =
Catmandu->importer('JSON', file => $self->file_name);
return $importer;
}
1;
__END__
=encoding utf-8
=head1 NAME
Datahub::Factory::Importer::JSON - Import data from JSON flat file data dump
ory;
use Data::Dumper qw(Dumper);
my $json = Datahub::Factory->importer('JSON')->new(
file_name => '/tmp/export.json',
);
$json->importer->each(sub {
my $item = shift
package JSON::API;
use strict;
use HTTP::Status qw/:constants/;
use LWP::UserAgent;
use JSON;
use Data::Dumper;
use URI::Encode qw/uri_encode/;
BEGIN {
use Exporter ();
use vars qw($VERSION @ISA @E
ication/json',
'Content-Type' => 'application/json',
);
if( $apphdr && ref $apphdr ) {
$headers->header( $_, $apphdr->{$_} ) foreach (keys %$apphdr);
}
my $json;
if (
defined $data) {
$json = $self->_encode($data);
return (wantarray ? (500, {}) : {}) unless defined $json;
}
my $req = HTTP::Request->new($method, $url, $headers, $json);
$self->_debug("Request
package eris::log::decoder::json;
# ABSTRACT: Decodes any detected JSON in a log line from then opening curly brace
use JSON::MaybeXS;
use Moo;
use namespace::autoclean;
with qw(
eris::role::dec
JSON Docs will start with a '{', check for it.
my $start = index($msg, '{');
if( $start >= 0 ) {
my $json_str = substr($msg, $start);
eval {
$decoded = decode_json
( $json_str );
1;
};
}
return $decoded;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
eris::log::decoder::json - Decodes any detected JSON in a log line from then op
e Test::DBChanges::Role::JSON;
use Moo::Role;
use JSON::MaybeXS ();
use namespace::autoclean;
our $VERSION = '1.0.2'; # VERSION
# ABSTRACT: decode data that's recorded as JSON
sub decode_recorded_d
) = @_;
return JSON::MaybeXS::decode_json($recoded_data);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Test::DBChanges::Role::JSON - decode data that's recorded as JSON
=head1 VERSION
ve
rsion 1.0.2
=head1 DESCRIPTION
Classes that store changes as JSON should consume this role.
=for Pod::Coverage decode_recorded_data
=head1 AUTHOR
Gianni Ceccarelli <gianni.ceccarelli@broadbean.co
st2::Tools::JSON::Pointer;
use strict;
use warnings;
use utf8;
use 5.008001;
use JSON::MaybeXS qw( JSON );
use Test2::Compare::JSON::Pointer;
use parent 'Exporter';
our @EXPORT = qw( json );
# ABST
RACT: Compare parts of JSON string to data structure using JSON pointers VERSION
our $VERSION = '0.02'; # VERSION
sub json ($;$)
{
my($pointer, $json) = @_ == 1 ? ('', $_[0]) : (@_);
my @caller
= caller;
Test2::Compare::JSON::Pointer->new(
file => $caller[1],
lines => [$caller[2]],
input => $json,
pointer => $pointer,
json => JSON->new->utf8(1),
);
}
my $co
package Test2::Compare::JSON::Pointer;
use strict;
use warnings;
use Test2::Util::HashBase qw( pointer input json );
use JSON::Pointer;
use Encode ();
use parent 'Test2::Compare::Base';
# ABSTRACT:
entation of a hash or array reference pointed to by a JSON pointer during deep comparison.
our $VERSION = '0.02'; # VERSION
sub operator { 'JSON PTR' }
sub name
{
my($self) = @_;
my($input, $po
t_root_ref = eval {
$self->{+JSON}->decode($self->_convert_got($got));
};
my $pointer = $self->{+POINTER};
my $id = [ META => $pointer eq '' ? 'JSON' : "JSON $pointer" ];
if(my $error =
package Anansi::Script::JSON;
=head1 NAME
Anansi::Script::JSON - Defines the mechanisms specific to handling JSON-RPC.
=head1 SYNOPSIS
my $OBJECT = Anansi::Script::JSON->new();
=head1 DESCRI
}}{$name} = $self->{CGI}->param($name);
}
}
=head2 medium
my $medium = Anansi::Script::JSON->medium();
my $medium = $OBJECT->medium();
my $medium = $OBJECT->channel('MEDIUM');
Re
hannel;
$channel = shift(@_) if(0 < scalar(@_));
return 'JSON-RPC';
}
Anansi::ScriptComponent::addChannel('Anansi::Script::JSON', 'MEDIUM' => 'medium');
=head2 parameter
my $parameters
package JSON::Schema::Fit;
$JSON::Schema::Fit::VERSION = '0.07';
# ABSTRACT: adjust data structure according to json-schema
use 5.010;
use strict;
use warnings;
use utf8;
use Carp;
use JSON;
use S
truc, $schema, $jpath) = @_;
return $struc if !$self->booleans();
return JSON::true if $struc;
return JSON::false;
}
sub _get_adjusted_integer {
my ($self, $struc, $schema, $jpath)
ath . "['$key']";
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
JSON::Schema::Fit - adjust data structure according to json-schema
=head1 VERSION
version 0.07
=head1 SYNOPSIS
my $data =