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}
cation/json" },
qq[{ "app": "<%= $class %>", "version" : "$<%= $class %>::VERSION" }])
->status_is(200, "posted version");
$t->get_ok('/clustericious/<%= $class %>')
->json_conten
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',
iles (initially XML or ini; the only thing making this difficult for JSON is that queries usually take more than one line, and JSON doesn't support multi-line strings).
=item * Finish up some more of
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(
=> '无',
rule => [],
},
]);
$c->render( json => {
result => 'false',
messages => $result->errors
}) if $result
:DBI::Test::SQLite;
{
$Hypatia::DBI::Test::SQLite::VERSION = '0.029';
}
use Moose;
use DBI;
use JSON;
use Path::Class;
use namespace::autoclean;
has 'sqlite_dir'=>(isa=>'Str', is=>'ro',default=>sub
my $table=$self->table;
my $json_str="";
$json_str.= " " .$_ while(<DATA>);
my $table_data=JSON->new->relaxed->utf8->decode($json_str);
my $found=0;
fo
se strict;
use Text::Xslate;
use JSON::XS;
use Benchmark qw(:all);
use Config; printf "Perl/%vd %s\n", $^V, $Config{archname};
foreach my $mod(qw(Text::Xslate JSON::XS)){
print $mod, '/', $mod-
>VERSION, "\n";
}
my $n = shift(@ARGV) || 10;
my %vpath = (
json => <<'TX',
<ul>
: for $books ->($item) {
<li><:= $item.title :> (<: $item.author :>)</li>
: }
</ul>
TX
);
my $tx = Text::Xsl
->new(
path => \%vpath,
cache_dir => '.xslate_cache',
cache => 2,
);
my $json = JSON::XS->new();
my %vars = (
books => [(
{ title => 'Islands in the stream',
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
ab installation via its API.
use strict;
use warnings;
use namespace::autoclean;
use Carp;
use JSON;
use LWP::UserAgent;
use Params::Validate::Checks ':all';
use Regexp::Common 'Email::Address';
content_type( 'application/json' );
$req->header( 'private_token' => $self->private_token )
unless $method->{ path } eq '/session';
$req->content( encode_json $data )
if keys %$d
;
my $res = $self->_ua->request( $req );
if ( $res->is_success ) {
return decode_json $res->content;
} else {
$self->error( $res->status_line );
return;
}
} #
:Riak::Fast::MapReduce::Phase::Map;
use Data::Riak::Fast::MapReduce::Phase::Reduce;
use JSON::XS qw/encode_json/;
with 'Data::Riak::Fast::Role::HasRiak';
=head1 DESCRIPTION
A map/reduce query.
=h
riak->send_request({
content_type => 'application/json',
method => 'POST',
uri => 'mapred',
data => encode_json({
inputs => $self->inputs,
query
all other operators will be derived from '""'
;
# be treated like an plain array by JSON::to_json()
sub TO_JSON {my $self = shift; return [@$self]}
# additional methods for Template Toolkit, if p
EACH %]
=head2 Interaction with JSON
Likewise, L<JSON/to_json> only exports objects who possess a C<TO_JSON()>
method; so such a method is also implemented here. JSON is really
reluctant to emit any
additional calls are
needed to make it work :
my $converter = JSON->new->allow_blessed->convert_blessed;
print $converter->to_json($schizophrenic); # ["FOO","BAR","BUZ"]
=head1 PUBLIC METHODS
},
@args
);
# Send job, data created by encoding @args with JSON
use JSON::XS;
$client->encoder(sub { encode_json(\@_) });
my $job2 = $client->put(
{ priority => 100,
ttr
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
subscription for a specific Shutterstock customer
use strict;
use warnings;
use Moo;
use JSON qw(encode_json);
use WebService::Shutterstock::LicensedImage;
use Carp qw(croak);
with 'WebService::Shu
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
,
sub {
my $self = shift;
my $client = $self->client;
$client->GET( sprintf( '/images/%s.json', $self->id ) );
my $data = $client->process_response(404 => sub {
return { is_available =>
milar {
my $self = shift;
my $client = $self->client;
$client->GET(sprintf('/images/%s/similar.json', $self->id));
my $images = $client->process_response;
return [ map { $self->new_with_client( '
a proxy class for the data returned from a URL
like L<http://api.shutterstock.com/images/15484942.json>. Please look
at that data structure for a better idea of exactly what each of the attributes
in
:JSON;
use Win32::API;
use Rex::Endpoint::HTTP::Interface::System;
sub free {
my $self = shift;
my $memory_info = $self->_iface->get_memory_statistics;
$self->render_json({ok => Mojo::JSON-
_json({ok => Mojo::JSON->true, max => $memory_info->{swap_size}});
}
sub used {
my $self = shift;
my $memory_info = $self->_iface->get_memory_statistics;
$self->render_json({ok => Mojo::JSON
ild__results_data {
my $self = shift;
my $client = $self->client;
$client->GET('/images/search.json', $self->query);
return $client->process_response;
}
sub page { return shift->_results_
PTION
This app will fork a ruby process that can handle rack requests.
Requests are converted to JSON and sent over a unix socket as a
netstring, a response is then read and used as the psgi response