y app_id/],
);
use Carp;
use Crypt::PK::RSA;
use Crypt::JWT qw/encode_jwt/;
use Furl;
use JSON qw/decode_json/;
use Time::Moment;
sub _lazy(&) {
return GitHub::Apps::Auth::Lazy->new($_[0]);
}
u
{
croak "fail to fetch installations: ". $resp->content;
}
my $content = decode_json $resp->content;
my %ids_by_account = map { $_->{account}{login} => $_->{id} } @$content;
Authorization => 'Bearer ' . $jwt,
Accept => "application/vnd.github.machine-man-preview+json",
];
}
sub _fetch_access_token {
my $self = shift;
my $installation_id = $self->ins
);
}
##
## toJson() and fromJson() are DUMP and SLURP equivalents for JSON.
## I'm not sure if they're all that useful yet so they're silently
## lurking here for now.
##
#sub toJson
#{
#my $self =
# croak("Cannot use toJson(): module JSON::XS not found.\n")
# unless (eval 'require JSON::XS; 1');
#
# my $ref = refaddr($self);
# my $json = JSON::XS->new();
# return $json->encode($STORAGE{$ref}
ess $str;
#
# croak("Cannot use fromJson(): module JSON::XS not found.\n")
# unless (eval 'require JSON::XS; 1');
#
# my $json = JSON::XS->new();
# my $obj = $json->decode($str);
# my $ref = refaddr
l';
use B;
# If Perl thinks a value is a string, JSON will encode it as such. But
# Transmission is picky about how parameters are encoded in the JSON
# request, so we make sure Perl knows how to sto
assword => $args->{password},
_call_start => 0,
}, $class;
# init json object
$self->_json;
# init useragent
$self->ua;
# authenticate
$self->auth;
return
return $self->{UserAgent};
}
sub _json {
my $self = shift;
unless ( defined $self->{JSON} ) {
$self->{JSON} = JSON::PP->new;
$self->{JSON}->ascii->pretty->allow_nonref->allo
w_blessed
->allow_bignum;
}
return $self->{JSON};
}
sub trace {
my $self = shift;
$self->{Trace} = $_[0]
if (@_);
return $self->{Trace};
}
sub debug {
my $s
sion::Torrent>
L<Transmission::Utils>
=cut
use Moose;
use DateTime;
use DateTime::Duration;
use JSON::MaybeXS;
use LWP::UserAgent;
use MIME::Base64;
use Transmission::Torrent;
use Transmission::Sess
UG'};
our $VERSION = '0.0806';
our $SESSION_ID_HEADER_NAME = 'X-Transmission-Session-Id';
my $JSON = JSON::MaybeXS->new;
with 'Transmission::AttributeRole';
=head1 ATTRIBUTES
=head2 url
$str = $
$id += 0 if($id =~ /^\d+$/);
}
}
$tag = int rand 2*16 - 1;
$post = $JSON->encode({
method => $method,
tag => $tag,
# ABSTRACT: request class
package PONAPI::Client::Request;
use Moose::Role;
use JSON::MaybeXS qw< encode_json >;
use PONAPI::Utils::URI qw< to_uri >;
requires 'method';
requires 'path';
has 'uri_
lf->_build_query_string )
: ( $self->can('data')
? ( body => encode_json( { data => $self->data } ) )
: ()
)
)
);
}
sub _buil
mple ();
use Carp ();
use File::Spec ();
use FindBin ();
use Hook::AfterRuntime ();
use JSON::PP ();
use Sub::Util 1.40 ();
1;
} || die($@) if ACTIVE;
};
our %CALL;
sub import {
my $
};
*{"$package\::$sub"} = $newcode;
}
END {
if (ACTIVE) {
my $JSON = 'JSON::PP'->new->pretty(1)->canonical(1);
my $map = $JSON->encode(\%CALL);
my $outfile = 'File::Spec'->catfile(
$Fi
very file "t/foo.t" in your test suite, Test::TraceCalls will
generate "t/foo.t.map" containing a JSON summary of which subs got
called by that test file.
=head1 DESCRIPTION
Test::TraceCalls will tr
# ABSTRACT: Client to a {JSON:API} service (http://jsonapi.org/) v1.0
package PONAPI::Client;
our $VERSION = '0.002012';
use Moose;
use JSON::MaybeXS qw( decode_json );
use PONAPI::Client::Request
der = (
( $args{body} ? ( 'Content-Type', 'application/vnd.api+json' ) : () ),
'Accept', 'application/vnd.api+json'
);
my ($status, $content, $failed, $e);
($status, $cont
atus};
$self->ua->after_request($res);
$content = $res->{body} ? decode_json( $res->{body} ) : '';
1;
}
or do {
($failed, $e) = (1, $@
prog]] bool,0,1 x,foo,bar,baz --format json-pretty --naked-res',
src_plang => 'bash',
summary => 'Like previous example, but outputs JSON',
},
],
};
sub permute_nam
$pkg->meta;
}
# dzil also wants to get abstract for main module to put in dist's
# META.{yml,json}
sub before_build {
my $self = shift;
my $name = $self->zilla->name;
my $class = $n
package Cisco::ACI;
use strict;
use warnings;
use Carp;
use JSON;
use HTTP::Request;
use LWP;
use XML::Simple;
use Cisco::ACI::Rule;
use Cisco::ACI::FvcapRule;
use Cisco::ACI::FvAEPg;
use Cisco::ACI
f = shift;
my $json = { aaaUser => { attributes => { name => $self->{ username }, pwd => $self->{ password } } } };
my $r = $self->__request( $self->__get_login_uri, to_json( $json ) );
return i
f $self->{ error };
$r = from_json( $r->content );
if ( defined $r->{ imdata } ) {
for my $a ( @LOGIN_ATTR ) {
$self->{ $a } = $r->{ imdata }->[0]->{ aaaLogin }->{ attributes }->{ $a }
}
}
,3 4,5 --json',
src_plang => 'bash',
summary => 'Same as previous example, but output JSON',
},
{
src => '[[prog]] 1,2 foo,bar --format json-pretty
package JSV::Compiler;
use strict;
use warnings;
use JSON;
use JSON::Pointer;
use URI;
use Path::Tiny;
use Carp;
use Storable 'dclone';
use Data::Dumper;
use Regexp::Common('RE_ALL', 'Email::Address',
} elsif ($file =~ /\.json/i) {
$self->{original_schema} = decode_json(path($file)->slurp_raw);
} else {
croak "Unknown file type: must be .json or .yaml";
}
$uri->clone;
$su->fragment("");
if ($self->{schemas}{$su}) {
my $rs = JSON::Pointer->get($self->{schemas}{$su}, $uri->fragment);
return $rs if $rs;
}
meters ) = @_;
$self->SUPER::_initialize( %parameters );
eval { require JSON::XS; };
$self->{ json } = JSON::XS->new->utf8;
} ## end sub _initialize
sub _finalize()
{
$log->debug( "_
('reply.time' => sub {
shift->respond_to(
html => {text => scalar localtime},
json => {json => {time => scalar localtime}},
);
});
$app->routes->get('/replytime')->to(cb => sub
that adds a
reply helper named "time" to the Mojolicious controller object. It will
respond to a JSON request with '{"time":"[scalar localtime]"}' and any other
request with a plain text response of
> 0,
};
}
sub grafana_rows {
my ( $self ) = @_;
my @rows;
push @rows, $self->get_json( 'ARC_metrics' );
return \@rows;
}
sub register_metrics {
return {
'arc_total' =
use warnings;
use strict;
use Data::Dumper;
use IPC::ShareLite;
use JSON::XS;
my $s = IPC::ShareLite->new(
-key => 1235,
-create => 1,
-destroy => 0,
) or die "can't create share: $
e Rarbg::torrentapi;
use strict;
use 5.008_005;
our $VERSION = 'v0.2.0';
use LWP::UserAgent;
use JSON;
use Carp;
use Rarbg::torrentapi::Res;
use Rarbg::torrentapi::Error;
use Moose;
our $BASEURL = '
Rarbg-torrentapi'
);
has _format => (
is => 'ro',
isa => 'Str',
default => 'json_extended'
);
has _ua => (
is => 'ro',
default => sub {
LWP::UserAgent->new(
" . $self->app_id;
my $res_json = $self->_ua->get($url);
if ( $res_json->is_success ) {
$self->_token_time(time);
my $res = decode_json( $res_json->decoded_content );
r
Dumper;
use JSON;
use RPi::WiringPi;
use RPi::Const qw(:all);
use WiringPi::API qw(:perl);
my $pi = RPi::WiringPi->new;
my $pin_num = 2;
my $j = $ENV{RPI_PINS};
my $p = $j ? decode_json $j : {};
die "pin in use...\n";
}
$p->{$pin_num}{alt} = $pi->get_alt($pin_num);
$p->{$pin_num}{state} = $pi->read_pin($pin_num);
print Dumper $p;
$j = encode_json $p;
say $j;
$ENV{RPI_PINS} = $j;
ecurity Monitor|http://www.zeek.org>.
If the L<JSON> module is installed, this module can also be used to parse Zeek log
files that were written in JSON format.
=head1 Constructor
The base construc