p;
use Moo;
use LWP::UserAgent;
use HTTP::Request::Common;
use URI::Escape;
use Data::Dumper;
use JSON;
use MIME::Base64;
use namespace::clean;
# ABSTRACT: communicates with DPD API
our $VERSION = '
GET',
path => '/shipping/job/',
header => {
Accept => 'application/json',
}
} );
}
=head2 get_labels_for_job( $id, $format )
Retrieves all label
data => { # hashref of data for POST/PUT requests, converted to JSON for sending
key1 => 'value1',
kage Mojolicious::Plugin::JSONP;
use Mojo::Base 'Mojolicious::Plugin';
our $VERSION = '0.04';
sub register {
my ($self, $app, $conf) = @_;
$app->helper(
render_jsonp => sub {
my ($sel
ethod(json => $ref, partial => 1) . ')')
: $self->render(json => $ref);
}
);
}
1;
__END__
=head1 NAME
Mojolicious::Plugin::JSONP - Render JSONP with transparent fallback to JSON
=hea
d1 SYNOPSIS
plugin JSONP => callback => 'callback_function';
get '/' => sub {
shift->render_jsonp({one => 'two'});
};
# GET request:
# ?callback_function=my_function
# Response:
k web applications
=head1 VERSION
version 0.03
=head1 SYNOPSIS
use Plack::Builder;
use JSON;
use Plack::Debugger;
use Plack::Debugger::Storage;
use Plack::App::Debugger;
us
panel',
serializer => sub { encode_json( shift ) },
deserializer => sub { decode_json( shift ) },
filename_fmt => "%s.json",
),
panels => [
Plack:
he necessary javascript and CSS for the debugging
UI. The second is to provide a small REST style JSON web-service that
serves up the debugging data.
=head2 C<Plack.Debugger>
This is the javascript
package App::RunCron::Announcer::Command;
use strict;
use warnings;
use JSON::PP;
sub new {
my ($class, $command) = @_;
$command = ref $command ? $command : [$command];
bless $command, $c
lass;
}
sub run {
my ($self, $runner) = @_;
open my $pipe, '|-', @$self or die $!;
print $pipe encode_json($runner->announce_data);
close $pipe;
}
1;
ge Bio::Taxonomy::GlobalNames;
use 5.10.0;
use strict;
use warnings;
use JSON qw(encode_json);
use JSON::Parse qw(parse_json);
use LWP::UserAgent;
use Moo::Lax;
use REST::Client;
use Scalar::Readonl
sing a REST client,
input is sent to the service, whereas results are internally converted
from JSON format to nested objects and returned to the user.
This module can be used for automated standar
resolvers.json';
}
elsif ( _check_status('http://resolver.globalnames.biodinfo.org') )
{
$gnr_url =
'http://resolver.globalnames.biodinfo.org/name_resolvers.json';
}
package App::RunCron::Reporter::Command;
use strict;
use warnings;
use JSON::PP;
sub new {
my ($class, $command) = @_;
$command = ref $command ? $command : [$command];
bless $command, $cl
$pipe, '|-', @$self or die $!;
my $d = $runner->report_data;
$d->{is_success} = $d->{is_success} ? $JSON::PP::true : $JSON::PP::false;
print $pipe encode_json($d);
close $pipe;
}
1;
use Try::Tiny;
use Scalar::Util qw[ blessed ];
use File::ShareDir;
use File::Spec::Unix ();
use JSON::XS ();
use Plack::App::File;
use Plack::Debugger;
our $VERSION = '0.03';
our $AUTHO
debugger';
# Be *extremely* lax about our JSON, this
# might be overkill for simple cases, but
# for non-simple cases, it just makes sense.
our $JSON = JSON::XS
->new
c_app'} = Plack::App::File->new( root => $args{'static_asset_dir'} )->to_app;
$args{'_JSON'} = $JSON;
$class->SUPER::new( %args );
}
# accessors ...
sub debugger { (shift)->{'
lp of the most excellent L<JSON::XS> but it's a bit fiddly, largely
because Perl doesn't natively support data types and Google's API accepts a
super-set of JSON - see L<JSON vs Javascript> below.
Th
is module is attempts to hide the gory details of preparing your data before
sending it to a JSON serializer - more specifically, hiding some of the hoops
that have to be jump through for making sure
, C<label>, C<pattern>, and C<p> are
supported. The contents of C<p> will be passed directly to L<JSON::XS> to
serialize as a whole.
=head2 Rows
A row is either a hash-ref where the keys are column
$opts{no_capture} = 1 if !defined $opts{no_capture};
$opts{dump} = 1 if $opts{yaml} || $opts{json};
if ($opts{metrics_path}) {
Module::CPANTS::Analyse->import(@{$opts{metrics_path}});
return CPAN::Meta::YAML::Dump($thingy);
} elsif ($self->{opts}{json} && eval { require JSON::PP }) {
my $coder = JSON::PP->new->utf8;
$coder->pretty if $pretty;
return $c
st});
}
my $extension =
$self->{opts}{yaml} ? '.yml' :
$self->{opts}{json} ? '.json' :
$self->{opts}{dump} ? '.dmp' :
'.txt';
require File::Spec;
File:
Send Requests to a JSON-RPC Service.
# We completely ride on the wonderful LWP Module.
{
package JRPC::Client;
#
use LWP;
use LWP::UserAgent;
use base ('LWP::UserAgent');
use JSON::XS;
use Data::Dump
er;
#our $mime;
#BEGIN {
# De-facto JSON-RPC Mime type
our $mime = 'application/json';
#};
=head1 NAME
JRPC::Client - JSON-RPC 2.0 Client
=head1 SYNOPSIS
use JRPC::Client;
my $client = JRP
so'}\n");
=head1 DESCRIPTION
JRPC::Client is a Perl LWP based JSON-RPC 2.0 Client hoping to minimize tedious boilerplate code for JSON-RPC
interaction, yet enabling advanced use cases by the power o
package JRPC::Nginx;
use JRPC;
use JSON::XS;
# require - to avoid symbol resolution problems ?
require nginx; # nginx / Nginx ?
use strict;
use warnings;
our $VERSION = "0.9";
# See Perldoc at the e
.
#This encapsulates the
#=cut
sub handle_2nd_stage {
my ($r) = @_;
my $jr = {'id' => $$, 'jsonrpc' => '2.0', };
my $buffer = $r->request_body();
eval {
# Parse Request
my $j =
now) that do not serialize
# well. Be ready to encounter exceptions here.
my $out = JSON::XS::encode_json($jr); # Serialize as a separate step to know length
################# Nginx Outpu
#{
package JRPC;
use JSON::XS;
use Data::Dumper;
use strict;
use warnings;
#UNUSED:my $rstub = {'id' => 66666, 'jsonrpc' => '2.0'};
our $VERSION = '0.61';
# 0 = No validation (trust client, any excep
Require 'id','jsonrpc', 3
our $msgvalid = 1;
# This is prelogger callback. MUST be a _hard_ CODE ref to be used (not symbolic reference).
our $prelogger;
=head1 NAME
JRPC - Create JSON-RPC Services
focusing on app logic, not worrying about the details of JSON-RPC Processing.
=head1 SYNOPSIS
use JRPC;
# Load one of the Service modules JRPC::CGI, JRPC::Apache2 or JRPC::Nginx
# See part
talsToBrowser warningsToBrowser/;
use JSON::XS;
use JRPC;
use strict;
use warnings;
use Scalar::Util ('reftype'); # Check base types
=head1 NAME
JRPC::CGI - JSON-RPC 2.0 Processing for CGI and HTTP:
:Server::Simple::CGI
=head1 DESCRIPTION
This package provides JSON-RPC 2.0 services processor for 2 runtimes based on:
=over 4
=item * CGI (CGI.pm) Plain old CGI scripting (or mod_perl ModPerl::Re
Keep this anywhere that may use CGI request object
sub CGI::uri {return $_[0]->script_name();}
# JSON RPC Response ID for malformed requests.
our $naid = 666666666;
=head2 JRPC::CGI::handle_cgi($cgi
);
# qw(OK)
use Apache2::Const -compile => qw(:common); # 'OK', 'DECLINED'
use APR::Table ();
use JSON::XS;
use JRPC; # Import ... ?
*jdie = JRPC::createfault;
#use Storable (); # Would import store -
ache2::RequestUtil;
=head1 NAME
JRPC::Apache2 - JSON-RPC Services in Apache2 / mod_perl runtime
=head1 DESCRIPTION
This package is a mod_perl JSON-RPC handler / dispatcher. It only contains the co
SetHandler modperl
PerlResponseHandler JRPC::Apache2
</Location>
=cut
# Parse and handle JSON-RPC Request.
# reads POST body by $r->read($buffer, $len).
# if/else dispatching (of 3 meth) give
erl
use Data::Dumper;
use JRPC::Client;
use JSON::XS;
use Getopt::Long;
#use threads;
use strict;
use warnings;
=head1 NAME
jrpc_client.pl - Generic JSON-RPC Client for JRPC toolkit
=head1 SYNOPSI
m * url - Service URL to send JSON-RPC request to
=item * method - JSON-RPC Method (e.g 'Pkg.meth' or just 'meth')
=item * parafile - JSON file with parameters for JSON-RPC "params" section
=back
tions (\%para, @pspec);
if (!$para{'url'}) {die("Need URL");}
#if (!$para{'parafile'}) {die("Need JSON-RPC Parameter file ('parafile')");}
if (!$para{'method'}) {die("Need 'method' (In valid format 'm
L<DBI>
=head3 L<DBD::SQLite>
=head2 Data Manipulation
=head3 L<Const::Fast>
=head3 L<JSON>
=head3 L<JSON::XS>
=head3 L<List::MoreUtils>
=head3 L<Regexp::Common>
=head3 L<XML::LibXML>
=head3
et::Twitch::Oauth2;
use strict;
use warnings;
use LWP::UserAgent;
use URI;
use URI::Escape;
use JSON::Any;
use Carp;
use constant ACCESS_TOKEN_URL => 'https://api.twitch.tv/kraken/oauth2/token';
u
e from twitch
##die and display error message
my $j = JSON::Any->new;
if (!$response->is_success){
my $error = $j->jsonToObj($response->content());
croak "'" .$error->{erro
}
##everything is ok proccess response and extract access token
my $reply = $j->jsonToObj($response->content());
my $token = $reply->{access_token};
my $expires = $reply->{re
et(
'https://api.twitch.tv/kraken/user' ##Twitch API URL
);
print $info->as_json;
=head1 DESCRIPTION
Net::Twitch::Oauth2 gives you a way to simply access Twitch.tv Oauth 2.0
e returned can be formatted as the following
=over 4
=item * C<$responseE<gt>as_json>
Returns response as json object
=item * C<$responseE<gt>as_hash>
Returns response as perl hashref
=bac
ldTimeS => 0,
name => "foo",
pendingTask => bless(do{\(my $o = 0)}, "JSON::PP::Boolean"),
updatedAt => "2014-12-04T00:41:14.120Z",
},
{
create
ldTimeS => 0,
name => "bar",
pendingTask => bless(do{\(my $o = 0)}, "JSON::PP::Boolean"),
updatedAt => "2014-12-04T00:42:13.231Z",
}]
=head2 browse_index
ask_status('foo', 29734242);
B<Response:>
{
pendingTask => bless(do{\(my $o = 0)}, "JSON::PP::Boolean"),
status => "published",
}
=head2 get_keys
Retrieves global API keys
e JSON::XS;
our $VERSION = '0.03';
our $AUTHORITY = 'cpan:STEVAN';
use parent 'Exporter';
our @EXPORT = qw[
result_generator
create_root
create_child
];
our $FILENAME_FMT = '%s.json';
our $JSON = JSON::XS->new->utf8->pretty;
{
my $UID_SEQ = 0;
my $UID_FMT = '%04d';
sub next_UID { sprintf $UID_FMT, ++$UID_SEQ }
}
sub result_generator {
my ($uid, $parent_u
my $root_uid = next_UID;
$dir->file( sprintf $FILENAME_FMT => $root_uid )
->spew( $JSON->encode( result_generator( $root_uid ) ) );
return $root_uid;
}
sub create_child {
my $d