re>.
The JBD namespace also contains lexing, parsing and grammar tools.
For JSON tokenizing and parsing, see L<JBD::JSON>.
For general parsing tools, see L<JBD::Parser>.
=head1 AUTHOR
Joel Dalley
ry::Tiny;
use JSON;
# extends ...
extends 'Monitoring::Spooler::Web';
# has ...
has 'json' => (
'is' => 'ro',
'isa' => 'JSON',
'lazy' => 1,
'builder' => '_init_json',
);
# with
...
# initializers ...
sub _init_json {
my $self = shift;
my $JSON = JSON::->new()->utf8();
return $JSON;
}
sub _init_fields {
return [qw(mode group_id queue message)];
}
# your co
_ref = $self->json()->decode($queue);
} catch {
$self->logger()->log( message => 'Failed to decode JSON: '.$_, level => 'warning', );
};
$queue = undef;
# if json decoding abo
package API::ParallelsWPB;
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
use JSON::XS;
use Carp;
use API::ParallelsWPB::Response;
use base qw/ API::ParallelsWPB::Requests /;
# A
confess "parameter post_data must be hashref or arrayref!"
}
$post_data = $self->_json->encode($data->{post_data});
}
$post_data ||= '{}';
my $response = $self->_send_requ
eq 'POST' || $data->{req_type} eq 'PUT' ) {
$req->header( 'content-type' => 'application/json' );
$req->content( $post_data );
}
$req->authorization_basic( $self->{username},
package WebService::ZombiesRun;
use v5.010;
use strict;
use warnings;
use autodie;
use Moo;
use JSON::Any;
use WWW::Mechanize;
use Data::Dumper;
our $DEBUG = 0;
use constant API_BASE => 'https://www
is => 'rw');
has agent => (is => 'lazy');
has json => (is => 'lazy');
sub _build_agent { return WWW::Mechanize->new; }
sub _build_json { return JSON::Any->new; }
sub runs_raw {
my ($se
join("/", API_BASE, "user/$user", $path, "?format=json");
warn "Calling $call\n" if $DEBUG;
$self->agent->get($call);
return $self->json->decode( $self->agent->content );
}
1;
__END__
=head1 ACKNOWLEDGEMENTS
YAML dumping code stolen from L<YAML::Tiny> (1.51).
=head1 SEE ALSO
L<JSON::Color>
At the time of this writing, none of syntax highlighting libraries on CPAN
support YAML.
ervice.
Choose class HTTP for a simple endpoint which just gets the whole ordered user list as a JSON
string. Chosse MS for a Monitoring::Spooler endpoint and Pingdom if you have an Pingdom account.
strict;
use warnings;
use Async::Chain;
use AnyEvent;
use AnyEvent::Loop;
use AnyEvent::HTTP;
use JSON;
use Data::Dumper;
my %state;
chain
sub {
my $next = shift;
http_get(
'http://api.metac
=1',
$next
);
},
sub {
my $next = shift;
my ($body, $headers) = @_;
%state = %{ from_json($body)->{hits}->{hits}->[0]->{fields} };
http_get "http://api.metacpan.org/v0/author/$state{aut
me", $next;
},
sub {
my $next = shift;
my ($body, $headers) = @_;
$state{realname} = from_json($body)->{name};
printf "%s (aka %s) release %s at %s\n", $state{realname}, $state{author}, $sta
e HTTP endpoints and complex plugins.
The simple HTTP plugins just receive the whole queue in as JSON encoded array.
Those only need to subclass App::Standby::Service::HTTP and provide an implementat
use MooseX::Params::Validate;
# use Carp;
# use English qw( -no_match_vars );
use Try::Tiny;
use JSON;
use LWP::UserAgent;
use URI::Escape;
# extends ...
extends 'App::Standby::Service';
# has ...
h
=> 1,
'builder' => '_init_ua',
);
has '_json' => (
'is' => 'rw',
'isa' => 'JSON',
'lazy' => 1,
'builder' => '_init_json',
);
has 'username' => (
'is' => 'rw'
nit_endpoints',
);
# with ...
# initializers ...
sub _init_json {
my $self = shift;
my $JSON = JSON::->new->utf8();
return $JSON;
}
sub _init_ua {
my $self = shift;
my $UA = LW
st);
use strict;
use constant URL => 'https://localbitcoins.com/bitcoincharts/%s/trades.json';
use constant ATTRIBUTES => qw(since);
use constant REQUEST_TYPE => 'GET';
use constant IS_PRI
ckage Word::Segmenter::Chinese::Lite::Dict;
use 5.008008;
use strict;
use warnings;
use JSON::XS qw(decode_json);
use Word::Segmenter::Chinese::Lite::Dict::Default;
require Exporter;
our @ISA =
(wscl_get_dict_default);
sub wscl_get_dict_default {
my $dict_default_hashref =
decode_json($Word::Segmenter::Chinese::Lite::Dict::Default::DICT_DEFAULT);
return %$dict_default_hashref;
;
use strict;
use constant URL => 'https://localbitcoins.com/bitcoincharts/%s/orderbook.json';
use constant ATTRIBUTES => qw(currency);
use constant REQUEST_TYPE => 'GET';
use constant IS_
8;
use DBIx::Sunny;
use Time::Piece;
use Digest::MD5 qw/md5_hex/;
use List::Util;
use Encode;
use JSON;
use Log::Minimal;
use List::MoreUtils qw/uniq/;
use List::Util qw/first/;
sub new {
my $cla
Y/%m/%d %T');
$row->{md5} = md5_hex( Encode::encode_utf8($row->{id}) );
my $ref = decode_json($row->{meta}||'{}');
$ref->{adjust} = '*' if ! exists $ref->{adjust};
$ref->{adjustval} =
ame description sort gmode color type stype llimit ulimit sllimit sulimit/;
my $meta = encode_json($args);
my $dbh = $self->dbh;
$dbh->query(
'UPDATE graphs SET service_name=?, sec
but then you are responsible for SSL cert verification code...
use LWP::UserAgent 6;
use URI;
use JSON;
use Data::Dumper;
## PUBLIC requests..
use Finance::LocalBitcoins::API::Request::Ticker;
use Fi
->uri . '?' . $uri->query);
}
$request->header(Accept => 'application/json');
# create a new user_agent each time...
$self->user_agent(LWP::UserAge
warn Data::Dumper->Dump([$self->http_response],['Response']) if DEBUG;
$content = $self->json->decode($self->http_response->content);
if (ref $content eq 'ARRAY') {
$self-
package GrowthForecast::Web;
use strict;
use warnings;
use utf8;
use Kossy 0.10;
use JSON;
use Time::Piece;
use GrowthForecast::Data;
use GrowthForecast::RRD;
use Log::Minimal;
use Class::Accessor::L
ta_dir float_number rrdcached disable_subtract/] );
use URI::Escape qw/uri_escape_utf8/;
my $_JSON = JSON->new()->allow_blessed(1)->convert_blessed(1)->ascii(1);
sub data {
my $self = shift;
ta->remove($c->stash->{graph}->{id});
$self->rrd->remove($c->stash->{graph});
$c->render_json({
error => 0,
location => "".$c->req->uri_for(sprintf('/list/%s/%s', map { uri_es
lude_filename => [qw/META.json cpanfile/] }
] # (core)
: [
'Git::GatherDir' =>
{ exclude_filename => [qw/META.json cpanfile/] }
: ()
),
'MetaYAML', # Generate META.yml (v1.4) (core)
'MetaJSON', # Generate META.json (vw) (core)
'CPANFile',
# Build system
'ExecDir', # Include
e files to include
[Git::GatherDir] ; Everything from git ls-files
exclude_filename = META.json ; Skip this generated file
[PruneCruft] ; Default stuff to skip
[ManifestSkip] ;
ture;
use JSON::PP;
my $g = Data::Random::Structure->new(
max_depth => 2,
max_elements => 5,
);
my $ref = $g->generate();
diag explain $ref;
my $json = JSON::PP->new;
'0.06'; #VERSION
use Catmandu::Sane;
use Moo;
use URI::Template;
extends 'Catmandu::Importer::getJSON';
has api => (
is => 'ro',
default => sub { 'http://www.wikidata.org/w/api.php' }
);
URI::Template->new(
$_[0]->api
. '?action=wbgetentities&format=json{&ids}{&sites}{&titles}'
);
}
);
has '+from' => (
is => 'ro',
lazy => 1,
options (C<ids>, C<site>, and/pr C<title>) or as line-separated
input values. By default, the raw JSON structure of each Wikidata entity is
returned one by one. Entities not found are returned with th
kigumo::Client::Notify::GitHubStatuses;
use strict;
use warnings;
use utf8;
use Mouse;
use JSON qw/encode_json/;
use Ukigumo::Constants;
has 'api_endpoint' => (
is => 'ro',
isa =>
state || !$description) {
# Nothing to do
return;
}
my $payload = encode_json({
state => $state,
target_url => $report_url,
description => $desc
data --items Q42,P19 to JSON --pretty 1
echo Q42 | catmandu convert Wikidata to JSON --pretty 1
catmandu convert Wikidata --site enwiki --title "Emma Goldman" to JSON --pretty 1
catmandu
convert Wkidata --title dewiki:Metadaten to JSON --pretty 1
catmandu convert Wikidata --title "Emma Goldman" \
--fix "wd_language('en')" to JSON --pretty 1
=head1 DESCRIPTION
B<Catmandu