sto::Client::ContentHandlers::JSON;
BEGIN {
$App::Presto::Client::ContentHandlers::JSON::AUTHORITY = 'cpan:BPHILLIPS';
}
{
$App::Presto::Client::ContentHandlers::JSON::VERSION = '0.009';
}
# ABST
izing of JSON requests/responses
use Moo;
my $HAS_JSON;
BEGIN {
eval 'use JSON; $HAS_JSON = 1;'
}
sub can_deserialize {
my $self = shift;
my $content_type = shift;
return unless $HAS_JSON;
retur
~ m{^application/json}i;
}
sub deserialize {
my $self = shift;
my $content = shift;
my $ref;
eval { $ref = JSON::decode_json($content) || 1 } or do {
warn "Unable to parse JSON: $@";
};
retur
1,
desc => 'Set content-type header',
args => sub { ['application/json','application/x-www-form-urlencoded'] },
proc => sub { $client->set_header( 'C
ON = '0.009';
}
# ABSTRACT: Manage configuration for a given endpoint
use Moo;
use JSON qw(decode_json encode_json);
use File::HomeDir;
use File::Path 2.08 qw(make_path);
has endpoint => (
is =
'HASH'; },
);
sub _build_config {
my $self = shift;
my $config_file = $self->file('config.json');
if (! -e $config_file ) {
warn "creating new config file: $config_file\n";
ode_json({});
close $fh;
}
my $config;
eval {
local $/;
open( my $fh, '<', $config_file ) or die "Unable to open $config_file for reading: $!";
my $json_te
data structures to STDOUT',
args => sub {
[ 'JSON', 'Data::Dumper', 'Data::Dump', 'YAML' ];
},
proc
able {
my $message = shift;
return $message->content_type =~ m{\b(?:xml|^text|application/json|application/x-www-form-urlencoded)\b} || do {
my $content = substr($message->decoded_cont
::Dumper::Sortkeys = 1;
return Data::Dumper::Dumper(shift);
},
'JSON' => sub { require JSON; return JSON->new->pretty->encode(shift) },
'YAML' => sub { require YAML; return YAML::D