package Devel::hdb::Client;
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Carp;
use Data::Dumper;
use URI::Escape qw();
use Data::Transform::ExplicitMetadata '0.02';
use Scalar::Util q
Exception::Error' => {
isa => 'Devel::hdb::Client::Exception',
},
);
my $JSON ||= JSON->new->utf8->allow_nonref();
sub new {
my $class = shift;
my %params = @_;
my %
$self->_GET($url);
_assert_success($response, q(Can't get stack position));
my $stack = $JSON->decode($response->content);
foreach my $frame ( @$stack ) {
$frame->{args} = _decode
dataset => "1k array of ints",
errors => 6.3e-06,
participant => "JSON::PP",
rate => 330,
samples => 20,
time => 3,
vs
{
dataset => "small arrays",
errors => 4e-08,
participant => "JSON::PP",
rate => 36000,
samples => 20,
time => 0.028,
{
dataset => "empty arrays",
errors => 3.3e-09,
participant => "JSON::PP",
rate => 128000,
samples => 20,
time => 0.00782,
}
my $res = $tx->res;
my $json = eval { $res->json };
if (not defined $json) {
$c->app->log->error( 'Decoding JSON response failed: ' . $@ );
$c->app->
rn $p->reject( 'x-unparseable-data-received' );
}
if (not $json->{'success'}) {
return $p->reject( @{ $json->{'error-codes'} // [] } );
}
return $p->resolve;
});
ta2>)',
},
{
module => 'JSON::PP',
code_template => 'JSON::PP::encode_json(<data1>) eq JSON::PP::encode_json(<data2>)',
},
{
fcall_t
benchmark.
L<Data::Cmp> 0.006
L<Data::Cmp::Numeric> 0.006
L<Data::Cmp::StrOrNumeric> 0.006
L<JSON::PP> 2.27400_02
L<Data::Compare> 1.25
=head1 BENCHMARK PARTICIPANTS
=over
=item * Data::Cmp::
:StrOrNumeric::cmp_data(<data1>, <data2>)
=item * JSON::PP (perl_code)
Code template:
JSON::PP::encode_json(<data1>) eq JSON::PP::encode_json(<data2>)
=item * Data::Compare::Compare (perl_cod
warnings;
use base qw/ WebService::PagerDuty::Base /;
use HTTP::Request;
use LWP::UserAgent;
use JSON;
use URI;
use URI::QueryParam;
use WebService::PagerDuty::Response;
__PACKAGE__->mk_ro_accessors
rams;
my $headers = HTTP::Headers->new;
$headers->header( 'Content-Type' => 'application/json' ) if %$body;
$headers->authorization_basic( $user, $password ) if $user && $password;
$h
'Authorization' => "Token token=$api_key" ) if $api_key;
my $content = '';
$content = to_json($body) if %$body;
my $request = HTTP::Request->new( $method, $url, $headers, $content );
use 5.010;
use strict;
use warnings;
use Carp 'croak';
use Hailo;
use JSON;
use LWP::UserAgent;
use POE qw(Wheel::Run Filter::JSON);
use Try::Tiny;
sub spawn {
my ($package, %args) = @_;
cro
t => '_child_stdout',
StderrEvent => '_child_stderr',
StdioFilter => POE::Filter::JSON->new,
( $^O eq 'MSWin32' ? ( CloseOnCall => 0 ) : ( CloseOnCall => 1 ) ),
);
$ke
N;
binmode STDOUT;
}
my $raw;
my $size = 4096;
my $filter = POE::Filter::JSON->new;
while (sysread STDIN, $raw, $size) {
my $requests = $filter->get([$raw]);
$self->header->{Accept} =
"application/vnd.pagerduty+json;version=" . $self->api_version;
$self->content_type('application/json');
$self->base_url('https://api.pagerduty.com');
$se
SL::Context::Default;
use Outthentic::DSL::Context::TextBlock;
use File::Temp qw/ tempfile /;
use JSON;
$Data::Dumper::Terse=1;
sub results {
my $self = shift;
$self->{results};
}
sub add
shift;
$self->{captures} = [];
unlink $self->{cache_dir}."/captures.json" if -f $self->{cache_dir}."/captures.json";
}
sub reset_succeeded {
my $self = shift;
$self->{succeeded} = [
ES, '>', $self->{cache_dir}.'/captures.json'
or confess "can't open ".($self->{cache_dir})."captures.json to write $!";
print CAPTURES encode_json($self->{captures});
$self->debug
1627';
}
## use critic
use strict;
use warnings;
use base qw/ WebService::PagerDuty::Base /;
use JSON;
use Error qw/ :try /;
my @all_options = qw/
code status message error
incident_key
total
essage();
$options->{errors} = undef;
try {
$options->{data} = from_json( $response->content() ) if $response->content();
}
otherwise {
my $er
that could happen and we care of - it's when $response->content can't
## be parsed as json (no difference why - because of bad request or something else)
$options->{data} = {
package Net::Azure::CognitiveServices::Face::Base;
use strict;
use warnings;
use HTTP::Tiny;
use JSON;
use Carp;
use URI;
sub new {
my ($class, %opts) = @_;
return bless {%opts}, $class;
}
s
$uri->query_form(%query);
}
$uri;
}
sub json {
my $self = shift;
$self->{json} ||= JSON->new->utf8(1);
$self->{json};
}
sub agent {
my $self = shift;
$self->{agen
content-type'};
if ($content_type !~ /application\/json/) {
croak($res->{content});
}
$body = $self->json->decode($res->{content});
}
if (!$res->{success})
gs;
our $VERSION = '0.10';
use overload '&{}' => sub { shift->to_app(@_) }, fallback => 1;
use JSON ();
use Digest::MD5 ();
use Scalar::Util ();
use Plack::Middleware::Chunked;
use SockJS
fo = JSON::encode_json(
{
websocket => $self->{websocket} ? JSON::true
: JSON::false,
cookie_needed => $self->{cookie} ? JSON::true
: JSON::fa
}
);
return [
200,
[
'Content-Type' => 'application/json; charset=UTF-8',
'Content-Length' => length($info),
],
[$info]
];
ct;
use warnings;
our $VERSION = "0.02";
use Moo;
use Crypt::PK::ECC 0.059;
use Crypt::JWT;
use JSON;
use Cache::Memory::Simple;
use AnyEvent;
use AnyEvent::Handle;
use AnyEvent::Socket;
use Protoc
collapse_id ? ('apns-collapse-id' => $apns_collapse_id) : (),
],
data => JSON::encode_json($payload),
on_done => $cb,
);
return $self;
}
sub send {
my $self =
if $version;
$config{idfile} = File::Spec->catfile( _metabase_dir(), '.metabase', 'metabase_id.json' ) unless $config{idfile};
$config{dbfile} = File::Spec->catfile( _metabase_dir(), '.metabase',
ibute
of the constructor
=head1 RESULTS
Results are returned as a Perl HashRef representing the JSON returned by the API.
=head1 SEE ALSO
L<https://apidocs.cloudhealthtech.com/>
There is a CLI wr
package SockJS::Session;
use strict;
use warnings;
use JSON ();
use Encode ();
sub new {
my $class = shift;
my (%params) = @_;
my $self = {};
bless $self, $class;
$self->{id}
encode('UTF-8', $message) if Encode::is_utf8($message);
}
else {
$message = 'a' . JSON->new->ascii(1)->encode([@_]) if @_;
}
return $self->{conn}->write($message);
}
sub clos
Your path manager
You can write path manager for your favoriet data manager (Data::DPath, JSON::Pointer, JSON::Path, etc)
B<Example:>
package QBit::Validator::PathManager::Data::DPath;
use bas
;
use strict;
use warnings;
use parent qw/Amazon::API/;
use Amazon::Credentials;
use JSON qw/from_json to_json/;
use Scalar::Util qw/reftype/;
use XML::Simple;
use Data::Dumper;
=pod
=head1 NAME
=> 'i-0b91d8e165cf2f41b'}]);
my $result = $ec2->DescribeInstances(Filter => $filter);
print to_json($result, { pretty => 1 });
=cut
sub DescribeInstances {
my $self = shift;
my %args = @_;
se LWP::Protocol::https;
use LWP::ConnCache;
use JSON qw(encode_json);
use Class::Accessor::Lite (
new => 0,
rw => [qw/ua api_url api_key json/],
);
use Carp qw(croak);
use WWW::FCM::HTTP::R
> 'key='.$self->api_key);
$req->header('Content-Type' => 'application/json; charset=UTF-8');
$req->content(encode_json $payload);
return $req;
}
1;
__END__
=encoding utf-8
=head1 NAME
head1 SYNOPSIS
use WWW::FCM::HTTP;
my $api_key = 'Your API key'; # from google-services.json
my $fcm = WWW::FCM::HTTP->new({ api_key => $api_key });
# send multicast request
ge CloudHealth::API::ResultParser;
use Moo;
use JSON::MaybeXS;
use CloudHealth::API::Error;
has parser => (is => 'ro', default => sub { JSON::MaybeXS->new });
sub result2return {
my ($
oudHealth::API::Error->throw(
type => 'UnparseableResponse',
message => 'Can\'t parse JSON content',
detail => $response->content,
) if ($@);
my $message;
if (defined $s
_api_id' },
{ name => 'api_version' },
{ name => 'name' },
] }
sub _url_params { [ ] }
sub _method { 'GET' }
sub _url { 'https://chapi.cloudhealthtech.com/api/search.json' }
1;