;
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) = @_;
shift;
print { $self->{outfh} } <<'END';
htrepl commands:
.header Content-Type application/json # set header
.header Content-Type # remove header
.cookie ID 12345
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
action => 'list',
columns => $self->columns
),
Content => encode_json(\@ids),
);
my $res = $self->_send($req);
return map { $self->class->thaw($_) } @{ $r
::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
(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
=> '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
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);
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
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
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":
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 ?
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;
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
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 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}
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
traits => 'CatalystX::Controller::ExtJS::REST::SimpleExcel::Trait';
use strict;
use warnings;
use JSON::XS ();
after list => sub {
my ($self, $c) = @_;
return unless($c->request->accepts('app
$rcopy = $rcopy->{$1};
}
push(@row, ref $rcopy->{$hcopy} ? JSON::XS::encode_json($rcopy->{$hcopy}) : $rcopy->{$hcopy} );
}
push(@rows, \@row);
}
ration helpers.
=head1 DESCRIPTION
Support DateTime::Duration "natively" by making sure they TO_JSON-ify
properly, and provide some useful extra helper methods.
=cut
package App::Pebble::Helpers::
no warnings "redefine";
=head2 METHODS
=cut
# Needed by Pebble::Object and JSON::XS
sub DateTime::Duration::TO_JSON {
my $self = shift;
###TODO: replace with format duration
$self->in
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