must be a B<Scalar> or B<HashRef> or B<ArrayRef>.
C<$robot-E<gt>brain-E<gt>data> will convert to json string and stored to external storage.
so, if you trying to store perl object, it will fail.
wit
qw(
.gitignore
Procfile
README.md
cpanfile
hubot-scripts.json
);
for my $file (@files) {
my ( $src, $dst )
= ( catfile("$dist_dir/
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
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
package Plack::App::Prack::Response;
use strict;
use warnings;
use JSON;
sub new {
my ($class, $sock) = @_;
die "socket is required" unless $sock;
my $self = bless { sock => $sock }, $class
de_json $self->read_ns;
$self->{body} = [];
while (my $chunk = $self->read_ns) {
push @{$self->{body}}, $chunk;
}
$self->{sock}->shutdown(0);
}
sub handle_error {
my ($self, $json)
= @_;
my $stack = decode_json $json;
die join "\n", map {$stack->{$_}} qw/name message stack/;
}
sub headers {
my $self = shift;
if ($self->{headers}) {
return [ %{$self->{headers}} ];
::HTTP::Login;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON;
# This action will render a template
sub index {
my $self = shift;
$self->render_json({ok => Mojo::JSON->true});
}
1;
package Net::WURFL::ScientiaMobile::Cache::Cookie;
use Moo;
use JSON qw(decode_json encode_json);
use Plack::Request;
with 'Net::WURFL::ScientiaMobile::Cache';
has 'cookie_name' => (is => 'rw
return 0 unless $request->cookies->{$self->cookie_name};
my $cookiedata = eval { decode_json($request->cookies->{$self->cookie_name}) };
return 0 unless ref $cookiedata eq 'HASH';
re
abilities => $capabilities,
};
$self->cookies({
$self->cookie_name => encode_json($data),
});
}
sub setDeviceFromID { 1 }
sub getMtime { 0 }
sub setMtime { 1 }
compare';
use AptPkg::Config '$_config';
use LWP::Simple 'mirror', 'RC_OK';
use Carp 'croak';
use JSON::Util;
use CPAN::Version;
use Storable 'dclone';
use List::MoreUtils 'uniq';
use File::is;
use D
filename } @existing;
if (mirror($url, $filename) == RC_OK) {
my $json_filename = $filename; $json_filename =~ s/\.bz2$/.json/;
my $content;
my $bz_content = IO::Any->slurp($filename);
b
ror\n";
JSON::Util->encode([$self->_parse_perlpackages_content($content)], $json_filename);
}
}
# remove no longer wanted indexes
foreach my $old_filename (@existing) {
my $json_filename =
escription => 'API Authentication error, your request signature is invalid',
},
);
use JSON qw(decode_json);
use List::Util qw(first sum);
use LWP::UserAgent;
use Module::Load qw(load);
use Moo;
u
(is => 'rw'); # The HTTP Request (PSGI env) that is being evaluated
has '_json' => (is => 'rw'); # The raw json response from the server
has '_report_data' => (is => 'rw', def
;
}
my $request_path = @{$self->_search_capabilities} == 0
? '/v1/json/'
: '/v1/json/search:(' . join(',', @{$self->_search_capabilities}) . ')';
# Prepare reques
ipt meta characters by yourself when you put data into
C<< <script> ... </script> >> sections.
C<JSON> module is not suitable because it doesn't escape some meta
characters such as C<< "</script>" >>
akeashorterlink makealongerlink);
our $VERSION = '0.1';
use Carp;
use JSON::RPC::Client;
our $RPC_URL = 'http://deb.li/rpc/json';
=head1 Functions
=over
=item B<makeashorterlink>(I<URL>)
The fun
akeashorterlink {
my $url = shift or croak 'No URL passed to makeashorterlink';
my $rpc = JSON::RPC::Client->new();
my $res
= $rpc->call( $RPC_URL => { method => 'add_url', params
or croak 'No key / URL passed to makealongerlink';
$key =~ s,^http://deb.li/,,;
my $rpc = JSON::RPC::Client->new();
my $res
= $rpc->call( $RPC_URL => { method => 'get_url', params
tion via SOAP. Dies on any error or SOAP
FAULT.
=item send_changes_json($message)
Helper method sending commit information via JSON-RPC. Dies on errors.
=back
=cut
require v5.10.0;
use base 'Clas
}
sub relay_message {
my ( $self, $client, $message, $opts ) = @_;
$self->send_changes_json( $client->repo_id,
{ method => 'relay_message', params => [$message, $opts] } );
}
sub s
);
}
}
sub send_changes_json {
my ( $self, $repo_id, $message ) = @_;
require JSON;
require JSON::RPC::Client;
my $rpc = JSON::RPC::Client->new();
$rpc->ua->timeo
,
sub {
my $self = shift;
my $client = $self->client;
$client->GET( sprintf( '/videos/%s.json', $self->id ) );
my $data = $client->process_response(404 => sub {
return { is_available =>
as a proxy class for the data returned from a URL
like L<http://api.shutterstock.com/videos/12345.json>. Please look
at that data structure for a better idea of exactly what each of the attributes
in
eLike::Base qw/ HashRef ArrayRef Str /;
use namespace::clean -except => 'meta';
use DateTime;
use JSON::Types;
use Message::Passing::Filter::Regexp::Log;
with qw/ Message::Passing::Role::Filter /;
us
output_to => 'decoder',
);
decoder decoder => (
class => 'JSON',
output_to => 'logstash',
);
filter logstash => (
class
]
output_to => 'encoder',
);
encoder("encoder",
class => 'JSON',
output_to => 'stdout',
output_to => 'es',
);
output std
PI -- KGB bot API documentation
=head1 VERSION 4 (JSON)
=head2 General, authentication
Version 4 uses JSON-RPC as described in
L<http://http://json-rpc.org/wiki/specification> with one extension. S
t-name
=item request-text
This is the JSON-encoded request text. The same that is sent in the HTTP body.
=back
=head2 Commit notification
Request is a JSON-RPC call to a method called B<commit_v4
jolicious::Controller';
use Mojo::JSON;
use MIME::Base64;
use Rex::Endpoint::HTTP::Interface::File;
sub open {
my $self = shift;
my $ref = $self->req->json;
eval {
$self->_iface->o
$self->render_json({ok => Mojo::JSON->true});
} or do {
$self->render_json({ok => Mojo::JSON->false});
};
}
sub read {
my $self = shift;
my $ref = $self->req->json;
my $fi
($file, $start, $len);
$self->render_json({ok => Mojo::JSON->true, buf => encode_base64($buf)});
} or do {
$self->render_json({ok => Mojo::JSON->false});
};
}
# this seems odd, but
s::ClientJobs;
=head1 NAME
Qless::ClientJobs
=cut
use strict; use warnings;
use JSON::XS qw(decode_json encode_json);
use Qless::Job;
use Qless::RecurringJob;
use Qless::Utils qw(fix_empty_array);
of job objects that are being tracked
=cut
sub tracked {
my ($self) = @_;
my $results = decode_json($self->{'client'}->_track());
$results->{'jobs'} = fix_empty_array($results->{'jobs'});
$result
agged with a tag
=cut
sub tagged {
my ($self, $tag, $offset, $count) = @_;
my $results = decode_json($self->{'client'}->_tag([], 'get', $tag, $offset||0, $count||25));
$results->{'jobs'} = fix_empt
package Rex::Endpoint::HTTP::Fs;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON;
use Mojo::Upload;
use Data::Dumper;
use MIME::Base64;
use Rex::Endpoint::HTTP::Interface::Fs;
# This actio
lf->_iface->ls($self->_path);
$self->render_json({ok => Mojo::JSON->true, ls => \@ret});
} or do {
$self->render_json({ok => Mojo::JSON->false});
};
}
sub is_dir {
my $self = shi
lf->_iface->is_dir($self->_path)) {
$self->render_json({ok => Mojo::JSON->true});
}
else {
$self->render_json({ok => Mojo::JSON->false});
}
}
sub is_file {
my $self = shift;
package Qless::Config;
=head1 NAME
Qless::Config
=cut
use strict; use warnings;
use JSON::XS qw(decode_json);
sub new {
my $class = shift;
my ($client) = @_;
$class = ref $class if ref $class;
$key) = @_;
if ($key) {
return $self->{'client'}->_config([], 'get', $key);
}
return decode_json($self->{'client'}->_config([], 'get'));
}
sub set {
my ($self, $key, $value) = @_;
return $sel
arnings;
use base 'Exporter';
our @EXPORT_OK = qw(fix_empty_array);
# Because of how Lua parses JSON, empty arrays comes through as {}
sub fix_empty_array {
my $val = shift;
if (!$val) {
return