rror_params},
});
Net::OpenXchange::X::OX is an exception class which is thrown when the JSON
response body from OpenXchange indicates an error.
=head1 ATTRIBUTES
=head2 error
Required, th
;
use Any::Moose 'X::Getopt';
use Any::Moose 'X::StrictConstructor';
use URI;
use JSON::XS;
use WWW::Mechanize;
our $VERSION = '0.01';
with any_moose('X::Getopt::Dashes')
= $mech->content;
# Get the raw JSON string
my ($json_string) = $cont =~ m[
\Qcontext.jsonArray.popups.pod_0200.push(\E\ (?<json>\{.*?\}) \Q);\E
]xm;
# D
ecode it into a Perl structure
my $json = decode_json($json_string);
my $reply = $json->{stringified};
return $reply;
}
sub run {
my ($self, $query) = @_;
itional Cache::Memcached hashing, both text and binary protocols,
serialization using Storable or JSON, and compression using gzip.
=head1 METHODS
=head2 new
C<new> takes a hash or a hashref contai
mespace::autoclean;
# ABSTRACT: Connection to OpenXchange server
use HTTP::Request::Common;
use JSON;
use LWP::UserAgent;
use Net::OpenXchange::X::HTTP;
use Net::OpenXchange::X::OX;
use URI;
has ur
eq,
response => $res,
}
);
}
my $resdataref = decode_json($res->content);
if ($resdataref->{error}) {
Net::OpenXchange::X::OX->throw(
ded
as well.
=head2 send
my $resdata = $conn->send($req);
Send the request and decodes the JSON response body. If there is an error, it
throws L<Net::OpenXchange::X::HTTP|Net::OpenXchange::X::H
::Response;
BEGIN {
$PowerDNS::API::Client::Response::VERSION = '0.10';
}
use Moose;
use JSON qw(decode_json);
use namespace::clean -except => 'meta';
has http => (
is => 'ro',
isa
1,
);
sub _build_data {
my $self = shift;
if ($self->http->content_type ne 'application/json') {
if ($ENV{API_DEBUG}) {
require Data::Dumper;
warn "PowerDNS::
code,
error => $self->http->status_line,
};
}
my $data = decode_json($self->http->decoded_content);
$data->{http_status} = $self->http->code;
if ($ENV{API_DEB
use HTML::Tested::JavaScript::Serializer;
use JSON::XS;
sub encode_value {
my ($self, $val) = @_;
no warnings 'numeric';
my $d = $val + 0;
return JSON::XS->new->allow_nonref->encode($val eq $d ?
is an exception class used for errors on the HTTP
level that occur before decoding OpenXchange's JSON response body.
=head1 ATTRIBUTES
=head2 request
Required, instance of L<HTTP::Request|HTTP::Re
ument? Then this module
will help you get that pony you've always wanted.
Consider the following JSON document:
{
"document_id": "QWERTY1",
"foo": "bar",
"yarg":
ormats
JSON_FT => "json",
XML_FT => "xml",
YAML_FT => "yaml",
TEXT_FT => "text",
HTML_FT => "html",
# Content Types
JSONP_CT => "text/javascript",
JSON_CT => "a
pplication/json",
XML_CT => 'text/xml',
YAML_CT => 'application/yaml',
TEXT_CT => "text/plain",
};
=head1 SYNOPSIS
Similar in functionality to the standard Dancer serialisation routi
a format using templates
=item Allows per-call configuration of default format
=item Works with jsonp
=back
use Dancer::Plugin::FormattedOutput;
get '/some/route' => sub {
my $dat
(JSONXSBool JSONPPBool)];
use MooseX::Types::Moose qw(Bool);
class_type JSONXSBool, { class => 'JSON::XS::Boolean' };
class_type JSONPPBool, { class => 'JSON::PP::Boolean' };
coerce Bool, from JSON
XSBool, via { 0 + $_ };
coerce Bool, from JSONPPBool, via { 0 + $_ };
1;
__END__
=pod
=head1 NAME
Net::OpenXchange::Types - Moose type library for Net::OpenXchange
=head1 VERSION
version 0.001
es =~ s#;//\]\]>\n</script>.*##s) if $res;
return $res;
}
sub Extract_JSON {
my ($n, $str) = @_;
my $et = Extract_Text($n, $str) // return;
return JSON::XS->new->allow_nonref->decode($et);
}
1;
action => 'list',
columns => $self->columns
),
Content => encode_json(\@ids),
);
my $res = $self->_send($req);
return map { $self->class->thaw($_) } @{ $r
=> 'YOUR KEY HERE',
API_FORMAT => 'json',
CACHE => 10,
DEBUG => 0,
MODULE_NAME => 'WWW::Wordnik::API',
USE_JSON => 0,
};
sub _fields {
{ server_ur
API_FORMAT,
cache => CACHE,
debug => DEBUG,
_formats => { json => 1, xml => 1, perl => 1 },
_versions => { 1 => 0, 2 => 0, 3 => 1, 4 => 1 },
_
),
_json => USE_JSON,
};
}
sub new {
my ( $class, %args ) = @_;
my $self = bless( _fields(), $class );
eval { require JSON; JSON->import() };
$self->{_json} = 'availabl
orean Translator
use utf8;
use Any::Moose;
use Any::Moose '::Util::TypeConstraints';
use JSON qw/decode_json/;
use Const::Fast;
use URI::Escape qw/uri_escape_utf8/;
use HTTP::Request;
use HTTP::Resp
src . '|' . $self->dst);
my $json = $self->get_json($escaped_uri);
$self->translated($json->{responseData}{translatedText});
return $json;
}
sub get_json {
my ($self, $url) = @_;
= $ua->request($req);
die $res->status_line, "\n" unless $res->is_success;
return decode_json($res->content);
}
__PACKAGE__->meta->make_immutable;
1;
__END__
=pod
=encoding utf-8
=head1
object to a Data::Pairs structure and
back.
The resulting structure may be serialized, e.g., as JSON or YAML.
=head1 SEE ALSO
MARC::Record
Data::Pairs
=head1 AUTHOR
Brad Baxter, E<lt>bbaxter@cpa
pp::REST;
use Moose;
use MooseX::Types::URI qw(Uri);
use LWP::UserAgent;
use HTTP::Request;
use JSON::XS;
use Module::Load;
use Data::Dumper;
=head1 NAME
CloudApp::REST - Perl Interface to the Clo
my $req = HTTP::Request->new;
$req->header(Accept => 'application/json');
$req->content_type('application/json');
$req->uri($uri);
$req->method('GET');
if (%bo
->_debug("Have content, method will be POST");
my $body_json = encode_json \%body;
$req->content($body_json);
$req->method('POST');
}
if (defined $
package App::Horris::CLI::Command::me2day;
# ABSTRACT: me2day Watcher
use Moose;
use DBI;
use JSON;
use AnyEvent;
use File::Temp;
use LWP::Simple;
use Const::Fast;
use DateTime::Format::W3CDTF;
use
extends 'MooseX::App::Cmd::Command';
const my $URL_FORMAT => "http://me2day.net/api/get_posts/%s.json";
has database => (
is => 'ro',
isa => 'Str',
traits =>
my $json_url = sprintf $URL_FORMAT, $id;
print "Checking $json_url\n";
my $data = get $json_url;
my $content = from_json($data);
package Horris::Connection::Plugin::Eval;
# ABSTRACT: Evaluate Plugin on Horris
use Moose;
use JSON;
use URI::Escape;
use HTTP::Request;
use LWP::UserAgent;
extends 'Horris::Connection::Plugin';
wit
=> $uri);
my $res = $ua->request($req);
if ($res->is_success) {
my $scalar = JSON::from_json($res->content, { utf8 => 1 });
return $scalar->{stderr} eq '' ? $scalar->{stdout}
THODS
=head2 new()
Object constructor.
=head2 TO_JSON()
Returns HashRef that is possible to give to C<encode_json()> function.
=cut
sub TO_JSON {
my $self = shift;
return {
map
(
'title' => 'Bar chart test',
);
print $chart->render_swf(600, 400, 'chart-data.json', 'test-chart');
OFC2 bar chart data:
use Chart::OFC2;
use Chart::OFC2::Axis;
use C
lash
Chart 2 is offering. But it should help you to starting creating OFC2
graphs quite fast. The JSON format is quite intuitive and can be created
from any hash. This module is more like guideline.
2 is a flash script for creating graphs. To have a graph we need an
F<open-flash-chart.swf> and a JSON data file describing graph data.
Complete examples you can find after successful run of this modu