item L<App::PAUSE::Comaint>
Power, just like love, is for sharing.
=item L<App::pretty>
Prints JSON/YAML structures in easier-on-the-eye tables.
=back
=head2 Web Development
=over
=item L<Dance
t;
my $ua = $self->ua;
$self->login($ua);
my $json = JSON->new;
my $treebank = $self->get_treebank($ua);
if($treebank) {
print $json->pretty->encode($treebank);
if (my $test_query =
}
if ($self->has_latitude && $self->has_longitude) {
push @$post, coordinates => JSON->new->encode({ latitude => $self->latitude, longitude => $self->longitude });
}
return $po
tract_usage };
sub run {
my $self = shift;
my $ua = $self->ua;
$self->login($ua);
my $json = JSON->new;
my $treebank = $self->get_treebank($ua);
if($treebank) {
$self->request_treeban
ss
use PMLTQ::Base -base;
use utf8;
use DBI;
use File::Slurp;
use Pod::Usage 'pod2usage';
use JSON;
use LWP::UserAgent;
use HTTP::Cookies;
use URI::WithBase;
use URI::Encode qw(uri_encode);
use En
$data) = @_;
my $JSON = JSON->new->utf8;
my $req = HTTP::Request->new( $method => $url );
$req->content_type('application/json;charset=UTF-8');
if($data) {
$data = $JSON->encode($data);
oded_content) unless $res->content_type eq 'application/json';
my $json = $res->decoded_content;
return ($res,$json ? $JSON->decode($json) : undef);
}
return $res;
}
sub get_all_treebanks
ct_usage };
sub run {
my $self = shift;
my $ua = $self->ua;
$self->login($ua);
my $json = JSON->new;
my $treebank = $self->get_treebank($ua);
my $treebank_param = $self->create_treeban
::VERSION = '2.0.3';
# ABSTRACT: GET current configuration
use PMLTQ::Base 'PMLTQ::Command';
use JSON;
use YAML::Tiny;
use Hash::Merge 'merge';
has usage => sub { shift->extract_usage };
sub run {
package Facebook::Graph::Request;
$Facebook::Graph::Request::VERSION = '1.1205';
use Moo;
use JSON;
use Ouch;
use LWP::UserAgent;
use LWP::Protocol::https;
use Facebook::Graph::Response;
has ua => (
package Facebook::Graph::Response;
$Facebook::Graph::Response::VERSION = '1.1205';
use Moo;
use JSON;
use Ouch;
has response => (
is => 'rw',
isa => sub {ouch(442,"$_[0] is not an HT
ult => sub {
my $self = shift;
return $self->response->content;
},
);
has as_json => (
is => 'ro',
lazy => 1,
default => sub {
my $self = shift;
}
else {
my $message = $response->message;
my $error = eval { JSON->new->decode($response->content) };
unless ($@) {
$message = $error->
::Graph;
$Facebook::Graph::VERSION = '1.1205';
use Moo;
use 5.006;
use MIME::Base64::URLSafe;
use JSON;
use Facebook::Graph::AccessToken;
use Facebook::Graph::Authorize;
use Facebook::Graph::Query;
us
load) = split(/\./, $signed_request);
my $sig = urlsafe_b64decode($encoded_sig);
my $data = JSON->new->decode(urlsafe_b64decode($payload));
if (uc($data->{'algorithm'}) ne "HMAC-SHA256") {
sha256($payload, $self->secret);
if ($sig ne $expected_sig) {
ouch '500', 'Bad Signed JSON signature!';
}
return $data;
}
sub request_access_token {
my ($self, $code) = @_;
uest to Facebook to fetch an access token. Returns a L<Facebook::Graph::Response> object. Example JSON response:
=head1 LEGAL
Facebook::Graph is Copyright 2010 - 2017 Plain Black Corporation (L<http
package Mojolicious::Plugin::JSONAPI;
$Mojolicious::Plugin::JSONAPI::VERSION = '2.6';
use Mojo::Base 'Mojolicious::Plugin';
use JSONAPI::Document;
use Carp ();
use Lingua::EN::Inflex
building JSON API compliant applications.
sub register {
my ($self, $app, $args) = @_;
$args ||= {};
my %jsonapi_args;
if (defined($args->{kebab_case_attrs})) {
$jsonapi_args
mespace})) {
# It's not really a JSONAPI::Document arg, but it's as close as
# we'll get to defining a base URL at startup time.
$jsonapi_args{namespace} = $args->{namespace};
lf->add_request($_) foreach @reqs;
my $json = JSON->new;
my $post = {
access_token => $self->access_token, # required
batch => $json->encode($self->requests),
};
$sel
unless ($resp->is_success) {
my $message = $resp->message;
my $error = eval { $json->decode($resp->content) };
unless ($@) {
$message = $error->{error}{type} . '
ould not execute batch requests: $message";
}
my $data = $json->decode($resp->decoded_content);
map { $_->{data} = $json->decode($_->{body}) } @$data;
return wantarray ? @$data : $dat
p;
use Scalar::Util 'looks_like_number';
use POSIX qw/ceil/;
use JSON::Create '0.22', 'create_json';
use JSON::Parse '0.42', 'parse_json';
our $VERSION = '0.08';
# eps is the allowed floating point e
n \@output;
}
sub save
{
my ($o) = @_;
return create_json ($o);
}
sub load
{
my ($o, $data) = @_;
my $input = parse_json ($data);
for my $k (keys %$input) {
$o->{$k} = $input->{
package JSONAPI::Document;
$JSONAPI::Document::VERSION = '2.4';
# ABSTRACT: Turn DBIx results into JSON API documents.
use Moo;
use Carp ();
use JSONAPI::Document::Builder;
use JSONAPI::Document::Bu
tions->{includes}) {
@relationships = @{ $options->{includes} };
}
my $builder = JSONAPI::Document::Builder::Compound->new(
api_url => $self->api_url,
fields
_related') {
$includes = [$row->result_source->relationships()];
}
my $builder = JSONAPI::Document::Builder->new(
api_url => $self->api_url,
fields
use UNIVERSAL::DOES;
use MIME::Types;
use LWP::UserAgent;
use HTTP::Request;
use File::Temp;
use JSON;
use YAML ();
my $ua = LWP::UserAgent->new;
$ua->agent("Tree_Query_CGI/1.0 ");
my $conf;
my $UR
} @$services)),
$cgi->end_html()
);
} elsif ($format eq 'json') {
print $cgi->header(-type => 'text/x-json',
-charset=>'UTF-8'
);
q 'json') {
print $cgi->header(-type => 'text/x-json',
-charset=>'UTF-8'
);
my $json = JSON->new->allow_nonref;
print $json->p
:PostCode::UK - Interface to the UK PostCode.
=head1 VERSION
Version 0.18
=cut
use 5.006;
use JSON;
use Data::Dumper;
use Address::PostCode::UserAgent;
use Address::PostCode::UK::Location;
use Add
s/\s//g;
my $url = sprintf("%s/postcode/%s.json", $BASE_URL, $post_code);
my $response = $self->get($url);
my $contents = from_json($response->{'content'});
my ($geo, $ward, $cou
s/postcode/nearest?postcode=%s&miles=%d&format=json", $BASE_URL, $post_code, $distance);
my $response = $self->get($url);
my $contents = from_json($response->{'content'});
my $locations =
kage JSONAPI::Document::Builder::Role::Attributes;
$JSONAPI::Document::Builder::Role::Attributes::VERSION = '2.4';
=head1 NAME
JSONAPI::Document::Builder::Role::Attributes - Utility role for JSON API
row) = @_;
$row //= $self->row;
my $sparse_fieldset = $self->fields;
if ($row->DOES('JSONAPI::Document::Role::Attributes')) {
my $columns = $row->attributes($sparse_fieldset);
package WWW::BetfairNG;
use strict;
use warnings;
use HTTP::Tiny;
use JSON::MaybeXS;
use IO::Uncompress::Gunzip qw/gunzip $GunzipError/;
use Carp qw /croak/;
# Define Betfair Endpoints
use constant B
tbeat/json-rpc/v1/';
use constant BF_RSTATUS_ENDPOINT => 'https://api.betfair.com/exchange/scores/json-rpc/v1/';
=head1 NAME
WWW::BetfairNG - Object-oriented Perl interface to the Betfair JSON API
ich allows registered users to interact with it
using a JSON-based API. This module provides an interface to that service which handles
the JSON exchange, taking and returning perl data structures (us
package JSONAPI::Document::Builder::Compound;
$JSONAPI::Document::Builder::Compound::VERSION = '2.4';
=head1 NAME
JSONAPI::Document::Builder::Compound - Compound Resource Document builder
=head1 VER
ent with all of its relationships and attributes.
=cut
use Moo;
extends 'JSONAPI::Document::Builder';
use Carp ();
use JSONAPI::Document::Builder::Relationships;
=head2 relationships
ArrayRef of
elf, $primary_row, $relationship, $fields, $options) = @_;
$options //= {};
my $builder = JSONAPI::Document::Builder::Relationships->new({
api_url => $self->api_url,
f