to the API for Todoist (a to-do list service)
use strict;
use warnings;
use LWP::UserAgent;
use JSON::XS;
use Carp 'croak';
use vars qw/$errstr/;
sub new {
my $class = shift;
my $args = sca
$args->{ua} = LWP::UserAgent->new(%$ua_args);
}
unless ( $args->{json} ) {
$args->{json} = JSON::XS->new->utf8->allow_nonref;
}
bless $args, $class;
}
sub errstr { $e
'LOGIN_ERROR' ) {
$errstr = $resp->content;
return;
}
my $data = $self->{json}->decode( $resp->content );
$self->{token} = $data->{api_token};
return $data;
}
sub get
package Net::Twitter::Loader;
use strict;
use warnings;
use JSON qw(decode_json encode_json);
use Try::Tiny;
use Carp;
use Time::HiRes qw(sleep);
our $VERSION = "0.04";
our @CARP_NOT = qw(Try::Tiny
$self->{filepath} or return undef;
my $json_text = do { local $/ = undef; <$file> };
close $file;
my $since_ids = try {
decode_json($json_text);
}catch {
my $e = shift;
$self->_log("warn", "failed to decode_json");
return {};
};
$since_ids = {} if not defined $since_ids;
return $since_ids;
}
sub _log {
my ($self, $level, $msg) = @_;
nder --template=template.html --values=values.json --output=output.html [--config=config.json]
# Render template tmpl.html with values from values.json into webpage.html
# You can use single-lett
ues.json -o webpage.html
# Same as above, but configure the template object using values from
# the config.json file
ht_render -t tmpl.html -V values.json -o webpage.html --config=config.json
:Template file.
=head2 --values
The path to the values file. The values file should describe a JSON object,
which will be parsed into a Perl hash. The keys of the hash should correspond
to varia
package Plack::App::JSONRPC;
use 5.008001;
use strict;
use warnings;
our $VERSION = "0.02";
use parent qw(Plack::Component);
use JSON::RPC::Spec;
use Plack::Request;
use Plack::Util::Accessor qw(rpc)
;
sub prepare_app {
my ($self) = @_;
my $rpc = JSON::RPC::Spec->new;
while (my ($name, $callback) = each %{$self->{methods}}) {
$rpc->register($name, $callback);
}
$self->
tent-Type' => 'application/json'], [$body]];
}
return [204, [], []];
}
1;
__END__
=encoding utf-8
=head1 NAME
Plack::App::JSONRPC - (DEPRECATED) Yet another JSON-RPC 2.0 psgi application
ostray;
$App::Nostray::VERSION = '1.01';
use File::Next;
use Getopt::Std;
use JavaScript::V8;
use JSON;
use File::Slurp;
=head1 NAME
App::Nostray - Detect and eliminate stray commas in Javascript so
head1 NAME
DJSON - Decommisioned. Use JSONY.pm instead.
=for html
<a href="https://travis-ci.org/ingydotnet/djson-pm"><img src="https://travis-ci.org/ingydotnet/djson-pm.png" alt="djson-pm"></a>
<a
ngydotnet/djson-pm?branch=master"><img src="https://coveralls.io/repos/ingydotnet/djson-pm/badge.png" alt="djson-pm"></a>
=head1 SYNOPSIS
use DJSON;
my $data = decode_djson $djson_string;
=head1 DESCRIPTION
DJSON is a data language that is simlar to JSON, just more chill. All valid
JSON is also valid DJSON (and represents the same thing when decoded), but
DJSON lets you omit a lot of
Curses::UI;
use LWP::UserAgent;
use LWP::Protocol::https;
use HTTP::Request;
use URI::Escape;
use JSON::XS;
use YAML::XS;
our $SELF;
sub PPP {
my $self = $SELF;
my $text = YAML::XS::Dump(@_);
rized. Maybe you need to login as an admin user?";
} else {
my $data = decode_json($response->content);
for (0 .. $#{$data}) {
my $user = $data->[$_];
$self->error("Couldn't login.");
return $self->logout;
}
my $token = decode_json($response->content)->{token};
$self->current_target->{user} = $username;
$self->current_t
easily find data, that you
can subsequently display. You can also use REST APIs that offer JSON but not
JSONP, directly from JavaScript.
=head1 CREDIT
This is just a simple way to use L<Plack::App:
JSONP;
use Plack::Middleware::Static;
use Plack::App::unAPI qw(0.3);
use File::ShareDir qw(dist_dir);
use Plack::Util;
use Carp qw(croak);
use Scalar::Util qw(blessed reftype);
use Try::Tiny;
use JSON
$self->query(@_) } ), $f->type ];
my $app = unAPI( %formats );
$app = Plack::Middleware::JSONP->wrap($app);
if ($self->{Stylesheet}) {
$app = Plack::Middleware::Static->wrap( $ap
e strict;
use 5.10.0;
use Carp;
use JSON;
use ZMQ::LibZMQ3;
use ZMQ::Constants qw(ZMQ_REP);
our $VERSION = "2.000000";
$VERSION = eval $VERSION;
my $json = JSON->new->utf8->convert_blessed;
my $MAX
>
and L<mcbain-zmq-client>, respectively.
The workers created by this module receive payloads in JSON format, and convert them into the
hash-refs your API's methods expect to receive. The payload mu
o the clients in JSON as well. Note that if an API method does not return a hash-ref, this runner
module will automatically turn it into a hash-ref to ensure that conversion into JSON will
be possible
ockIO;
use 5.006;
use strict;
use warnings FATAL => 'all';
use Carp;
use WWW::Curl::Simple;
use JSON;
use Exporter 'import';
our @EXPORT_OK = qw(get_new_address
get_my_addresses
aw_from_user
get_current_price);
=head1 NAME
Finance::BlockIO - Perl wrapper to JSON-based Block.io API
=head1 VERSION
Version 0.01
=cut
our $VERSION = '0.02';
=head1 SYNOPSIS
provides a bare interface to the Block.io JSON-based API,
using WWW::Curl::Simple to make requests and returning a Perl data structure
created from any JSON response received.
You'll probably need a
}
sub psgi {
my ($self, $result) = @_;
my $json = JSON->new->encode( $result );
return [ 200, [ "Content-Type" => $self->type ], [ $json ] ];
}
1;
__END__
=pod
=encoding UTF-8
=head1
use warnings;
use strict;
use Carp;
use Gearman::XS qw(:constants);
use Gearman::XS::Worker;
use JSON;
our $VERSION = "2.000000";
$VERSION = eval $VERSION;
=head1 NAME
McBain::WithGearmanXS - Loa
orkers created receive payloads in JSON format, and convert them into the hash-refs your
API's methods expect to receive. Results are sent back to the clients in JSON as well. Note
that if an API meth
ref, this runner module will automatically
turn it into a hash-ref to ensure that conversion into JSON will be possible. The created
hash-ref will have one key - holding the method's name, with whatev
SCRIPTION
No user-serviceable parts inside. See L<Net::Async::SPORE::Loader> instead.
=cut
use JSON::MaybeXS;
=head2 new
Instantiates this object.
=cut
sub new { my $class = shift; bless { @_ }
eq) = @_;
$self->_transport->do_request(
request => $req
)->transform(
done => sub { decode_json(shift->content) }
)
}
1;
__END__
=head1 AUTHOR
Tom Molesworth <cpan@perlsite.co.uk>
=head1
efine.h" */
/* #include "str_array.h" */
/* #include "match_entry.h" */
#ifdef ENABLE_JSON
#include <json-c/json.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct _edge;
struct _node;
struct
_JSON
json_object * r3_edge_to_json_object(const edge * e);
json_object * r3_node_to_json_object(const node * n);
json_object * r3_route_to_json_object(const route * r);
const char * r3_node_to_json_
string_ext(const node * n, int options);
const char * r3_node_to_json_pretty_string(const node * n);
const char * r3_node_to_json_string(const node * n);
#endif
#ifdef __cplusplus
}
#endif
#endif /*
;
use Plack::App::WebSocket;
use Scalar::Util qw(weaken refaddr);
use Try::Tiny;
use JSON qw(decode_json encode_json);
our $VERSION = "0.03";
sub new {
my ($class, @args) = @_;
my $self = $c
e_str) = @_;
return if !$self;
try {
my $message = decode_json($message_str);
if(!ref($message) || ref($message) ne "HASH") {
> sub {
my ($send_message) = @_;
try {
$conn->send(encode_json($send_message));
}catch {
my $e = shift;
return !$sel
Archives;
use strict;
use warnings;
use 5.10.0;
use Carp;
use LWP::UserAgent;
use URI;
use JSON qw(decode_json);
our $VERSION = '0.03';
sub new {
my ($class, %args) = @_;
if(!defined($args{u
!$res->is_success) {
croak "Network Error: " . $res->status_line;
}
return decode_json($res->content);
}
1;
__END__
=pod
=head1 NAME
WebService::Lingr::Archives - load archived me
erver
use warnings;
use strict;
use Carp;
use JSON;
use Net::WebSocket::Server;
our $VERSION = "2.000000";
$VERSION = eval $VERSION;
my $json = JSON->new->convert_blessed;
=head1 NAME
McBain::W
:WebSocket::Server>.
The created server will be a JSON-in JSON-out service. When a client sends a message to
the server, it is expected to be a JSON string, which will be converted into a hash-ref
an
to JSON as well and sent back to the client.
Note that if an API method does not return a hash-ref, this runner module will automatically
turn it into a hash-ref to ensure that conversion into JSON w
MtAws::LineProtocol;
our $VERSION = '1.120';
use strict;
use warnings;
use utf8;
use Carp;
use JSON::XS;
use App::MtAws::Utils;
use Exporter 'import';
our @EXPORT = qw/ get_data send_data/;
our @
n unit-test it (JSON and YAML have different serialization implementeation)
my $json_coder = JSON::XS->new->ascii(1)->allow_nonref;
sub decode_data
{
my ($data_e) = @_;
return $json_coder->decode($
data_e);
}
sub encode_data
{
my ($data) = @_;
return $json_coder->encode($data);
}
sub get_data
{
my ($fh) = @_;
my ($len, $line);
sysreadfull_chk($fh, $len, 8) &&
sysreadfull_chk($fh, $lin
etrieve_inventory
{
my ($self, $format) = @_;
$format or confess;
if ($format eq 'json') {
$format = 'JSON';
} elsif ($format eq 'csv') {
$format = 'CSV';
} else {
confess "unknown invent
ype;
if ($ct eq 'text/csv') {
INVENTORY_TYPE_CSV
} elsif ($ct eq 'application/json') {
INVENTORY_TYPE_JSON
} else {
confess "Unknown mime-type $ct";
}
};
return ($resp->content, $it
resp->content_type && $resp->content_type eq 'application/json') {
my $json = JSON::XS->new->allow_nonref;
my $scalar = eval { $json->decode( $resp->content ); }; # we assume content always