package Plack::App::Prack::Request;
use strict;
use warnings;
use JSON;
use Plack::App::Prack::Response;
my @ENV_KEYS = qw/REQUEST_METHOD PATH_INFO QUERY_STRING
SERVER_NAME SERVE
ift;
return length($data).":".$data.",";
}
sub write {
my $self = shift;
my $env = encode_json($self->_filter_env($self->{env}));
my $input = "";
my $buf = "";
while ($self->{env}->{'p
package Data::Riak::Fast;
use Mouse;
use JSON::XS qw/decode_json/;
use URI;
use Data::Riak::Fast::Result;
use Data::Riak::Fast::ResultSet;
use Data::Riak::Fast::Bucket;
use Data::Riak::Fast::MapRed
@parts
],
}
);
}
sub _buckets {
my $self = shift;
return decode_json(
$self->send_request({
method => 'GET',
uri => '/buckets',
,
uri => $request_str
});
}
sub stats {
my $self = shift;
return decode_json(
$self->send_request({
method => 'GET',
uri => '/stats',
erAgent;
use JSON;
# default options
use constant DEFAULT_USER_AGENT => 'Mozilla/5.0';
use constant DEFAULT_LANG => 'en-US';
use constant BASE_URL => 'http://imdbapi.org/?type=json';
use Obje
earch($options);
if ( $response->is_success ) {
my @results;
for ( @{ decode_json( $response->content ) } ) {
my $result = WebService::IMDBAPI::Result->new( %{$_} );
nse->is_success ) {
my $result = WebService::IMDBAPI::Result->new(
%{ decode_json( $response->content ) } );
return $result;
}
else {
die $response->status
Test::Mojo>, and add the following new attributes and methods.
=cut
use base 'Test::Mojo';
use JSON::XS;
use YAML::XS;
use File::Slurp qw/slurp/;
use Carp;
use List::Util qw(first);
use Clustericio
t = $t->testdata('filename');
Looks for filename, filename.json, filename.yaml in 't', 'data' or
't/data' directories. Parses with json or yaml if appropriate, then
returns the object.
=cut
sub
ml", "$_.json" }
map { $_, "t/$_", "data/$_", "t/data/$_" }
$filename;
my $content = slurp($filename) or croak "Missing $filename";
return decode_json($conten
package Data::Riak::Fast::MapReduce::Phase::Link;
use Mouse;
use JSON::XS ();
# ABSTRACT: Link phase of a MapReduce
with ('Data::Riak::Fast::MapReduce::Phase');
=head1 DESCRIPTION
A map/reduce li
sub pack {
my $self = shift;
my $href = {};
$href->{keep} = $self->keep ? JSON::XS::true() : JSON::XS::false() if $self->has_keep;
$href->{bucket} = $self->bucket if $self->has_buck
ackage Data::Riak::Fast::MapReduce::Phase::Map;
use Mouse;
use Mouse::Util::TypeConstraints;
use JSON::XS ();
# ABSTRACT: Map phase of a MapReduce
with ('Data::Riak::Fast::MapReduce::Phase');
=hea
=cut
sub pack {
my $self = shift;
my $href = {};
$href->{keep} = $self->keep ? JSON::XS::true() : JSON::XS::false() if $self->has_keep;
$href->{language} = $self->language;
$href->{name}
l::DTrace::Provider;
use 5.008;
use strict;
use warnings;
use vars qw/ $DTRACE_AVAILABLE /;
use JSON;
BEGIN {
our $VERSION = '1.11';
require XSLoader;
eval {
XSLoader::load('Devel::D
ak::Fast::MapReduce::Phase::Reduce;
use HTTP::Headers::ActionPack::LinkList;
use JSON::XS qw/decode_json encode_json/;
with 'Data::Riak::Fast::Role::HasRiak';
=head1 DESCRIPTION
Data::Riak::Fast:
ets/%s/keys', $self->name),
query => { keys => 'true' }
})->first;
return decode_json( $result->value )->{'keys'};
}
=head2 count
Count all the keys in a bucket. This uses MapReduce
ce->mapreduce;
my ( $result ) = $map_reduce_results->results->[0];
my ( $count ) = decode_json($result->value) || 0;
return $count->[0];
}
=head2 remove_all
Remove all the keys from a bu
;
use LWP::UserAgent;
use JSON;
use URI::Escape ();
# see http://www.pingdom.com/services/api-documentation-rest/
# use autodie;
# use MooseX::Params::Validate;
has '_json' => (
'is' =>
'ro',
'isa' => 'JSON',
'lazy' => 1,
'builder' => '_init_json',
);
has '_ua' => (
'is' => 'rw',
'isa' => 'LWP::UserAgent',
'lazy' => 1,
'builder' =>
nt('Pingdom::Client/0.01');
return $UA;
}
sub _init_json {
my $self = shift;
my $JSON = JSON::->new()->utf8();
return $JSON;
}
sub _set_lasterror {
my $self = shift;
my $c
enu::ToJSON;
use 5.008;
use strict;
use warnings FATAL => 'all';
use Carp;
use parent 'HTML::Widgets::NavMenu::Object';
use JSON qw(encode_json);
=head1 NAME
HTML::Widgets::NavMenu::ToJSON - con
idgets::NavMenu to JSON
=head1 VERSION
Version 0.0.1
=cut
our $VERSION = '0.0.1';
=head1 SYNOPSIS
use HTML::Widgets::NavMenu::ToJSON;
use HTML::Widgets::NavMenu::ToJSON::Data_Persistence
avMenu::ToJSON::Data_Persistence::YAML->new(
{
filename => '/path/to/persistence_data.yaml',
}
);
my $obj = HTML::Widgets::NavMenu::ToJSON->new(
ON = '1.00';
}
# ABSTRACT: Provides access to the v3 Bukget API
use Mojo::Base '-base';
use Mojo::JSON;
use Mojo::UserAgent;
use Try::Tiny qw/try catch/;
use boolean;
has '_ua' => sub
>get($u)) {
if(my $res = $tx->success) {
$args->{on_success}->($self => $res->json) if(defined($args->{on_success}));
} else {
my ($err, $code) = $tx->error;
=over 4
=item * on_success - A coderef that gets the WebService::Bukget instance and the decoded JSON result as parameters
=item * on_failure - A coderef that gets an arrayref of code and status as
}
use strict;
use warnings;
use Redis;
use JSON::XS;
use Encode qw/encode_utf8 decode_utf8/;
sub load {
my ( $class, $robot ) = @_;
my $coder = JSON::XS->new->convert_blessed;
my $redis =
cted to redis-server\n" if $ENV{DEBUG};
my $json = $redis->get('hubot:storage') || '{}';
$robot->brain->mergeData( decode_json( decode_utf8($json) ) );
$robot->brain->on(
'save',
ub {
my ( $e, $data ) = @_;
my $json = $coder->encode($data);
$redis->set( 'hubot:storage', encode_utf8($json) );
}
);
$robot->brain->on( 'close', s
ge namespace.
For example, Pipeline refers to Data::Pipeline::Pipeline while
JSON refers to Data::Pipeline::Adapter::JSON.
=head2 Aggregators
Aggregators allow multiple actions to be strung togethe
rts sending simple string
messages, but it works way better when is provided with
L<Log::Message::JSON(3)> or L<Log::Message::Structured(3)> object, because the
structure of the message will be preser
es as messages. This option
tells how should be named key if the message is not
a L<Log::Message::JSON(3)>/L<Log::Message::Structured(3)> object.
=item I<hostname_field> (default: I<none>)
Fluentd o
RRAY' && @$msg == 1;
# repack message
if (eval { $msg->isa('Log::Message::JSON') }) {
# strip Log::Message::JSON blessing
# NOTE: the resulting hash(ref) should be tied to Tie::IxHash, bu
CLI. named `hubot`
$ perldoc hubot
# make sure `hubot-scripts.json` is exist in current working directory
use JSON::XS;
use Cwd 'cwd';
use Hubot::Robot;
my $robot = Hubot::Ro
ptsFile = "$cwd/hubot-scripts.json";
if (-f $scriptsFile) {
my $json = read_file($scriptsFile);
my $scripts = decode_json($json);
$robot->lo
t::Scripts::tweet;
{
$Hubot::Scripts::tweet::VERSION = '0.1.3';
}
use strict;
use warnings;
use JSON::XS;
sub load {
my ( $class, $robot ) = @_;
$robot->hear(
qr/https?:\/\/(mobile\
ps://api.twitter.com/1/statuses/show/'
. $msg->match->[1]
. '.json' )->get(
sub {
my ( $body, $hdr ) = @_;
r
^2/ );
print "$body\n" if $ENV{DEBUG};
my $tweet = decode_json($body);
$msg->send("$tweet->{user}{screen_name}: $tweet->{text}");
illa;
{
$Hubot::Scripts::bugzilla::VERSION = '0.1.0';
}
use utf8;
use strict;
use warnings;
use JSON::XS;
my %PRIORITY_MAP = (
'---' => '☆☆☆☆☆',
Lowest => '★☆☆☆☆',
★★☆',
Highest => '★★★★★',
);
sub load {
my $client = JSONRPC->new( { url => $ENV{HUBOT_BZ_JSONPRC_URL} } );
my ( $class, $robot ) = @_;
$robot->hear(
qr/b(?:u
);
}
);
}
sub speak_bug {
my ( $msg, $body, $hdr ) = @_;
my $data = decode_json($body);
my $bug = @{ $data->{result}{bugs} ||= [] }[0];
$msg->send(
sprintf "#%s
se strict;
use warnings;
use URI;
use URI::QueryParam;
use HTTP::Request;
use LWP::UserAgent;
use JSON::XS;
use Encode 'decode';
sub load {
my ( $class, $robot ) = @_;
$robot->hear(
q
$ENV{HUBOT_BITLY_API_KEY},
longUrl => $bitly,
format => 'json'
);
my $ua = LWP::UserAgent->new;
my $req = HTTP
>request($req);
return unless $res->is_success;
my $data = decode_json( $res->content );
$bitly = $data->{data}{url};
}
$msg->h
Hubot::Scripts::print;
$Hubot::Scripts::print::VERSION = '0.1.10';
use strict;
use warnings;
use JSON::XS;
sub load {
my ( $class, $robot ) = @_;
$robot->hear(
qr/^(?:print|say):? (.
return if ( !$body || $hdr->{Status} !~ m/^2/ );
my $data = decode_json($body);
$msg->send( split /\n/,
$data->{stdout} || $d
extends 'Hubot::Adapter';
use AnyEvent;
use AnyEvent::HTTP;
use AnyEvent::Campfire::Client;
use JSON::XS;
use Encode 'encode_utf8';
use HTTP::Request;
use LWP::UserAgent;
use Try::Tiny;
use Hubot::
),
);
$req->header( 'Accept', 'application/json' );
$req->header( 'Authorization', $bot->authorization );
my $res
cess;
my $userData;
try {
$userData = decode_json( $res->content );
}
catch {
$bot->emit( 'erro