se Test::More;
use LWP::UserAgent;
use HTTP::Request;
use LWP::Protocol::https;
use JSON;
use JSON::Parse 'parse_json';
use IO::Socket::SSL;
my $const_sin = "TeyN4LPrXiG5t2yuSamKqP3ynVk3F52iHrX";
my
$request->header('content-type' => 'application/json');
my %content = ('id'=>$sin);
my $jsonc = encode_json \%content;
$request->content($jsonc);
my $ua = LWP::UserAgent->new;
my $response
WebService::VirusTotal;
use 5.006;
use strict;
use warnings;
use Carp;
use LWP::UserAgent;
use JSON;
use Digest::SHA qw(sha1_hex sha256_hex);
use Digest::MD5 qw(md5_hex);
use List::Util qw(first);
lls the sha256 value out of the JSON response
# Note: there are many other values that could also be pulled out
my $json = JSON->new->allow_nonref;
my ($decjson, $sha, $respcode) = (undef, un
$decjson = $json->decode($results);
};
if (defined $decjson)
{
# if json->decode() fails it will call croak, so we catch it and display the returned text
$sha = $decjson->{"sha256"};
E
WWW::StatsMix - Interface to StatsMix API.
=head1 VERSION
Version 0.07
=cut
use 5.006;
use JSON;
use Data::Dumper;
use WWW::StatsMix::Stat;
use WWW::StatsMix::Metric;
use WWW::StatsMix::UserAg
an;
extends 'WWW::StatsMix::UserAgent';
has format => (is => 'ro', default => sub { return 'json' });
has metrics_url => (is => 'ro', default => sub { return 'http://api.statsmix.com/api/v2/metr
mat});
my $response = $self->post($self->metrics_url, [ %$params ]);
my $content = from_json($response->content);
return WWW::StatsMix::Metric->new($content->{metric});
}
=head2 update
$self->serial_format($1);
}
else {
$self->serial_format('json');
}
}
# this ISA trickery has 2 benefits:
# (1) a default new() method
should serialized Perl values be assumed to be? The default is C<yaml>.
You might also specify C<json>. If you have serialized values in some other format,
then you'll need to subclass SWISH::API::Ob
'x($bad_char-1).'^';
return $msg;
}
1;
__END__
=pod
=head1 NAME
Parse::JCONF - Parse JCONF (JSON optimized for configs)
=head1 SYNOPSIS
use strict;
use Parse::JCONF;
my $raw_c
\"Moo\", \"Mo\")"
=head1 DESCRIPTION
JSON is good, but not very handy for configuration files. JCONF intended to fix this.
It has several differences with JSON format:
=over
=item bareword - the
ONF value
=item values in the object/array or root trines may be devided with comma "," (like in JSON) or with new line (or even several)
val = [1,2,3,4] # with comma
val = [ #
server_info:
server: http://solr.example.com/productSearch/
format => JSON
server_version: 4.5
=head2 alias
Aliases allow you to reference the same underlying s
get_parameters_from_file
get_list_from_file
get_column_data
read_json_file
write_json_file
run
run_time
readable_second
check_positive_integer
ode_utf8 /;
use File::Path qw(make_path remove_tree);
use File::Find;
use File::Basename;
use JSON;
=head1 NAME
BioUtil::Util - Utilities for operation on data or file
Some great modules
get_parameters_from_file
get_list_from_file
get_column_data
read_json_file
write_json_file
run
run_time
readable_second
check_positive_integer
= "0.03";
use parent qw/Exporter/;
use MIME::Base64 qw/encode_base64url/;
use Digest::SHA;
use JSON::WebToken qw//;
use Net::OpenID::Connect::IDToken::Exception;
use Net::OpenID::Connect::IDToken:
, $extra_headers) = @_;
JSON::WebToken->encode($claims, $key, $alg, $extra_headers);
};
our $JWT_DECODE = sub {
my ($id_token, $key, $to_be_verified) = @_;
JSON::WebToken->decode($id_toke
}
}
Other errors like 'id_token itself is not valid JWT' might come from
underlying JSON::WebToken.
=head2 ERROR_IDTOKEN_INVALID_ALGORITHM
Thrown when invalid algorithm specified.
=he
trict;
use warnings;
use 5.010;
use Carp;
use autodie;
use utf8;
use Moo;
use HTTP::Request;
use JSON;
use Net::HTTP::Spore;
use List::Util qw/first/;
use Scalar::Util qw/blessed weaken/;
use Data::U
default => sub { File::ShareDir::dist_file('WebService-Zaqar', 'marconi.spore.json') });
has 'client_uuid' => (is => 'ro',
lazy => 1,
bu
payloads serialized/deserialized to/from JSON -- except if
# you're receiving 401 or 403
$client->enable('+WebService::Zaqar::Middleware::Format::JSONSometimes');
# set X-Auth-Token heade
}
elsif ($serializer eq 'JSON') {
require JSON::XS;
$serialize_methods = [\&JSON::XS::encode_json, \&JSON::XS::decode_json];
}
}
if ($serialize_
rmat::JSONSometimes;
# ABSTRACT: middleware for JSON format
use JSON;
use Moose;
extends 'Net::HTTP::Spore::Middleware::Format';
has _json_parser => (
is => 'rw',
isa => 'JSON',
lazy => 1,
default => sub { JSON->new->utf8(1)->allow_nonref },
);
sub encode { $_[0]->_json_parser->encode( $_[1] ); }
sub decode { $_[0]->_json_parser->decode( $_[1] ); }
sub acc
ept_type { ( 'Accept' => 'application/json' ) }
sub content_type { ( 'Content-Type' => 'application/json;' ) }
sub should_serialize {
my $self = shift;
$self->_check_serializer( shift->env,
package Gcis::Client;
use Mojo::UserAgent;
use Mojo::Base -base;
use Mojo::Log;
use JSON::XS;
use YAML::XS qw/LoadFile/;
use Path::Class qw/file/;
use Data::Dumper;
use Time::HiRes qw/sleep/;
use v5.1
gger => sub { state $log ||= Mojo::Log->new(); };
has json => sub { state $json ||= JSON::XS->new(); };
has accept => "application/json";
has 'tx';
sub auth_hdr { ($a = shift->key) ? ("Autho
ssage});
return;
};
my $json = $res->json or do {
$s->logger->debug("no json from $path : ".$res->to_string);
$s->error("No JSON returned from $path : ".$res->to_string
ints;
use YAML::Tiny;
use Data::Dumper;
enum 'Format', [qw(YAML XML JSON)];
enum 'Process', [qw(sox play)];
enum 'TTY', [qw(STDOUT STDERR)];
enum 'Handle', ['
se Moo;
use Text::MarkdownTable;
use IO::Handle::Util ();
use IO::File;
use JSON::XS ();
with 'Catmandu::Exporter';
# JSON Table Schema
has schema => (
is => 'ro',
coerce => sub {
my
chema, "r");
die "failed to load JSON Table Schema from $schema" unless $fh;
local $/;
$schema = JSON::XS::decode_json(<$fh>);
}
$schema;
}
);
ne client:
echo '{"one":"my","two":"table"} {"one":"is","two":"nice"}' | \
catmandu convert JSON --multiline 1 to Table
| one | two |
|-----|-------|
| my | table |
| is | nice |
};
$self->{'__ua'}->env_proxy();
# Check if JSON is available
if (eval { require JSON; }) {
$self->{'__format'} = 'json';
} else {
$self->{'__format'} = 'perl';
{
my $result;
if ($self->{'__format'} eq 'json') {
return unless $result = JSON::from_json($res->content());
} else {
## no critic
liar
with it.
=head1 DEPENDENCIES
LWP::UserAgent
Data::UUID
LWP::protocol::https
If JSON.pm is installed, JSON format is used when making requests to API;
otherwise Data::Dumper format is used. Not
iny;
use constant DEFAULT_FORMAT => 'YAML';
enum 'Format', [qw(YAML XML JSON)];
has 'format' => (
is => 'rw',
isa => 'Format',
);
has 'p
die "Regrettably, this is not a valid format option. Choose one of ( [o] YAML, [x] JSON or [x] XML." if $@;
return(0);
}
sub begin {
my $self = shift
t;
use LWP::UserAgent;
use Carp qw/carp croak/;
use JSON qw/to_json from_json/;
use 5.010;
use strict;
use warnings;
sub __handle_error;
sub __json_request;
=head1 NAME
WWW::Challonge - Perl wrapp
to get some content and check the response code:
my $response = $client->get("$HOST/tournaments.json?api_key=$key");
# Check for any errors:
WWW::Challonge::__handle_error $response if($response-
->{key};
my $client = $self->{client};
# The intial request URL:
my $req = "$HOST/tournaments.json?api_key=$key";
# Loop through the options (if any) and add them on:
for my $option(keys %{$opt
use WWW::Challonge;
use WWW::Challonge::Match::Attachment;
use Carp qw/carp croak/;
use JSON qw/to_json from_json/;
sub __args_are_valid;
=head1 NAME
WWW::Challonge::Match - A class representing a
Make the PUT call:
my $response = $client->request(WWW::Challonge::__json_request(
"$HOST/tournaments/$url/matches/$id.json", "PUT", $params));
# Check for any errors:
WWW::Challonge::__han
tches/$id.json?api_key=$key");
# Check for any errors:
WWW::Challonge::__handle_error $response if($response->is_error);
# If not, save it and then return it:
$self->{match} = from_json($respons
s;
use WWW::Challonge;
use HTTP::Request::Common qw/POST/;
use Carp qw/carp croak/;
use JSON qw/to_json from_json/;
sub __args_are_valid;
sub __is_kill;
=head1 NAME
WWW::Challonge::Match::Attachmen
keys %{$args};
my $request = POST(
"$HOST/tournaments/$url/matches/$match_id/attachments/$id.json",
"Content-Type" => 'form-data',
"Content" => [ "api_key" => $key, @params ],
);
$request->
all:
my $response = $client->delete(
"$HOST/tournaments/$url/matches/$match_id/attachments/$id.json?api_key=$key");
# Check for any errors:
WWW::Challonge::__handle_error $response if($response-
se WWW::Challonge::Participant;
use WWW::Challonge::Match;
use Carp qw/carp croak/;
use JSON qw/to_json from_json/;
sub __is_kill;
sub __args_are_valid;
=head1 NAME
WWW::Challonge::Tournament - A c
# Make the PUT request:
my $response = $client->request(WWW::Challonge::__json_request(
"$HOST/tournaments/$url.json", "PUT", $params));
# Check for any errors:
WWW::Challonge::__handle_error
hallonge::HOST;
# Make the DELETE call:
my $response = $client->delete("$HOST/tournaments/$url.json?api_key=$key");
# Check for any errors:
WWW::Challonge::__handle_error $response if($response-