use strict;
use feature qw(say);
use Web::Scraper;
use URI;
use Data::Dumper;
use JSON::XS;
use HTML::TreeBuilder::LibXML;
use LWP::UserAgent;
use HTTP::Message;
use Template;
my $template = Templat
q('$_')} @urlparams_opt),
};
push(@{$api->{$endpoint}},$details);
}
}
my $json = JSON::XS->new->pretty;
say $json->encode($api);
sub get_page {
my ($url) = @_;
my $ua = LWP::UserAgent->new
e dir.
This POD also contains examples of schemas.
=head1 EXAMPLES
The examples are written in JSON with Javascript-style comments (C<// comment>).
=head2 Various simple examples
// integer, opt
te::JSONCodec;
our $VERSION = '0.1_1';
use v5.14;
use strictures 2;
use Moo::Role;
use Carp;
use JSON ();
use namespace::clean;
=item _json (read-only)
A L<JSON> codec object.
=cut
has _json =>
is => lazy => init_arg => undef, builder => sub {
JSON->new->utf8->allow_blessed(1)
};
1;
package Minion::Backend::Pg91;
use Mojo::Base 'Minion::Backend';
use Mojo::IOLoop;
use Mojo::JSON qw(j);
use Mojo::Pg;
use Sys::Hostname 'hostname';
use Carp 'croak';
use Mojo::Util qw(dumper);
our
, task)
values (?, ?, (now() + (interval '1 second' * ?)), ?, ?, ?, ?)
returning id", { json => $args }, $options->{attempts} // 1,
$options->{delay} // 0, $options->{parents} // [],
now(), status = ? where id = ? returning 1';
return $id if $id && $self->pg->db->query($sql, { json => $options->{status} // {} }, $id)->rows;
$sql = q{insert into minion_workers (id, host, pid,
ost of the
functionality of C</render>, C</metrics/expand>, C</metrics/find> and
C</metrics/index.json> which is described in detail in
L<Net::Async::Graphite::API>.
There is also support to pass the
HTTPClient>.
JSON data is decoded using a L<JSON> object handled by
L<Net::Async::Graphite::JSONCodec>.
=cut
with 'Net::Async::Graphite::HTTPClient';
with 'Net::Async::Graphite::JSONCodec';
=head
=item find
=item expand
=item index[.json]
C</metrics/index.json> can be requested with C<$method> of C<index> or
C<index.json> because requiring the C<.json> suffix is silly. Also I
can consider
llowed_metrics_params{'index.json'} = $allowed_metrics_params{index}; # FFS
sub metrics {
my $self = shift;
my ($method, $query, %extra) = @_;
$method = 'index.json' if $method eq 'index';
re
mages in the gallery. For example the main gallery is https://api.imgur.com/3/gallery/hot/viral/0.json
=back
B<Parameters>
=over 4
=item *
C<sort> I<optional>
viral | top | time | rising (only
# ],
# 'Cpuset' => '',
# 'MemorySwap' => 0,
# 'AttachStdin' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ),
# 'AttachStderr' => $VAR1->{'Config'}{'AttachStdin'},
# 'CpuShares' => 0,
# 'Ope
'JWT',
alg => 'RS256'
};
my $t = Mojo::JSON->new->encode($s);
require Data::Dump;
say Data::Dump::dump($t);
say Data::Dump::dump(Mojo::JSON->new->decode($t));
say MIME::Base64::encode_
base64url($t);
my $a = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9';
say Data::Dump::dump(Mojo::JSON->new->decode(MIME::Base64::decode_base64url($a)));
}
subtest q{header} => sub {
ok $jwt->header, '
ate_key => path('data/privatekey.pem')->slurp)), 'decode(encode())';
delete @$jwt{qw( header body signature json cipher private_key )};
is_deeply $jwt2, $jwt, 'Round trip';
};
};
done_testing();
use strict;
use warnings;
use utf8;
use HTML::Entities qw{encode_entities};
use HTTP::Tiny;
use JSON;
use POSIX qw{:locale_h};
use URI::Escape qw{uri_escape_utf8};
#
# The “my” keyword is on a
_options_ => shift,
_base_ => 'https://translate.yandex.net/api/v1.5/tr.json',
_post_ => undef,
_http_ => HTTP::Tiny->new
};
$self->{_text_} = u
sponse->{content}) {
my $json_respond = JSON->new->utf8->decode($response->{content});
return (wantarray) ? @{ $json_respond->{dirs} } : scalar(@{ $json_respond->{dirs} });
}
}
su
se Digest::SHA qw< sha1_hex sha256_hex >;
use Digest::MD5 qw< md5_hex >;
use Term::ANSIColor;
use JSON::PP;
use File::Path;
use File::Find;
use File::Copy;
use warnings;
use strict;
=head1 NAME
Ap
;
sub read_json {
open(my $fh,"<", "$base_path/packages.json") || die "cant open: $base_path/packages.json: $!";
my $json = <$fh>;
my $p = decode_json $json;
}
sub write_json {
my @p
et_packages(shift)};
my $json = encode_json \@p;
open(my $fh,">", "$base_path/packages.json") || die "cant open: $base_path/packages.json: $!";
print $fh $json;
}
sub printer {
my @p
;
if ($res->is_success) {
delete @$self{qw(code content error message)};
my $j = $res->json;
$self->{snakecase($_)} = $j->{$_} for keys %$j;
return $self->success(1);
}
else {
sprintf 'Error (%u): %s', $_[0]->code, $_[0]->message);
if ($res and my $j = $res->json) {
# Got JSON body in response
$self->content($j);
my $m = ref($j->{error}) ? $j->{error}
use strict;
use warnings;
use utf8;
use HTML::Entities qw{encode_entities};
use HTTP::Tiny;
use JSON;
use POSIX qw{:locale_h};
use URI::Escape qw{uri_escape_utf8};
my
$VERSION = '0.02';
my %valid_
ult_ui = map { $_ => 1 } qw{ en ru tr };
my %valid_format = map { $_ => 1 } qw{ json xml };
my $default_format = 'json';
my $james_axl_result = sub
{
my $self = shift;
die "You must set API
$self->{_lang_}.'&ui='.$self->{_ui_};
my $response = $self->{_http_}->get($self->{_base_} . '.json' . $query . $post);
die "Invalid API key.\n" if ($response->{status} eq '401');
die "Bloc
e warnings;
{
use URI;
use Carp;
use Readonly;
use LWP::UserAgent;
use JSON qw( from_json );
use Storable qw( store retrieve );
use HTTP::Status qw( HTTP_BAD_REQUEST );
if !$self{key};
croak "data_format must either be Perl or JSON"
if $self{data_format} !~ m{\A (?: perl|json ) \z}xmsi;
$self{ua} = LWP::UserAgent->new();
$self{ua}->agen
\%form );
$response = $self->{ua}->get($uri);
}
my $json = $response->content() || "";
my ($message) = $json =~ m{ "message" \s* : \s* "( [^"]+ )" }xms;
$message ||= $respo
.com/json/$ip";
my $response = $self->dispatch(url => $url ,method => 'GET');
my $status = $response->status_line;
my $json_response = $response->decoded_content;
return $json_res
=item data_format
This is either 'json' or 'perl'. If you indicate 'json' then you'll get the
raw JSON as given by the remote API. Otherwise, the JSON::from_json function
is used to transform the r
>grant_type,
assertion => $jwt->encode
})->res;
if ($res->is_success) {
my $j = $res->json;
return undef unless ref $j eq 'HASH' and $j->{expires_in};
return $j->{access_token};
me_type_to_description = (
'application/javascript' => 'Javascript',
'application/json' => 'JSON data',
'application/pdf' => 'PDF document',
'application/xhtml+xml' => 'W
t yet documented.
=cut
no indirect;
use Future;
use Dir::Self;
use URI;
use URI::Template;
use JSON::MaybeXS;
use Syntax::Keyword::Try;
use File::ShareDir ();
use Log::Any qw($log);
use Path::Tiny
:Async::TravisCI::Config;
use Net::Async::TravisCI::Job;
use Net::Async::TravisCI::Build;
my $json = JSON::MaybeXS->new;
=head2 configure
Applies configuration, which at the moment would involve ze
<share/endpoints.json> file.
=cut
sub endpoints {
my ($self) = @_;
$self->{endpoints} ||= do {
my $path = Path::Tiny::path(__DIR__)->parent(3)->child('share/endpoints.json');
$path
Arn => $self->target->Arn,
Id => $self->target->Id,
Input => $input->json,
},
],
});
}
__PACKAGE__->meta->make_immutable;
1;