qw();
use Scalar::Util qw( blessed );
sub filename { return 'schema' }
sub suffix { return '.json' }
my $cache;
sub check {
my ( $self, $data ) = @_;
if ( not exists $cache->{ _CLASS($self
_CLASS($self) }->check($data);
}
sub decode_file {
my ( $self, $file ) = @_;
require JSON;
return JSON->new()->utf8(1)->relaxed(1)->decode( scalar $file->slurp() );
}
sub _make_rx {
my ($se
ta::Rx::Tools::ShareDirValidator';
sub filename { 'schema' } # default value.
sub suffix {'.json'} # default value.
1;
...
Later:
use Foo;
Foo->check({ some => [ 'data', 'structure'
ated using the C<new_with_config> method. A number
of file formats are supported (e.g. XML, YAML, JSON, Apache-style,
Windows INI), see the L<Config::Any> documentation for full
details. The default v
use JSON;
use List::MoreUtils ();
use Moose::Util ();
BEGIN { extends 'Catalyst::Controller'; }
__PACKAGE__->config(
default => 'application/json',
map => { 'application/json' =>
/twitter/tweet/$id
Will return the document C<$id>. If L</raw_get> is set to false, the returned
JSON will not include the ElasticSearch metadata. Instead the C<_source> or
C<fields> property is retu
This helper action can be used to return a error message to the client.
The client will receive a JSON response that includes the message and
the error code. If the message is a L<ElasticSearch::Error
>setup_indexing('bucket_name');
Does the same as :
curl -X PUT -H "content-type:application/json" http://localhost:8098/riak/bucket_name -d '{"props":{"precommit":[{"mod":"riak_search_kv_hook","
earch(
q => 'bucket_name.field:value'
);
Search the index
=over 4
=item wt => 'XML|JSON'
defines the response format (XML is the default value as for Solr/Lucene)
=item q
the query s
package App::jt;
{
$App::jt::VERSION = '0.43';
}
# ABSTRACT: JSON transformer
use 5.010;
use Moo;
use MooX::Options;
use JSON::PP;
use IO::Handle;
use Hash::Flatten qw(flatten unflatten);
use List:
8";
return $io;
}
);
option 'ugly' => (
is => "ro",
doc => "Produce uglyfied json output"
);
option 'pick' => (
is => "ro",
format => "i@",
autosplit => "..",
doc
the objects by given code. %_ containing the object content."
);
option 'json_path' => (
is => "ro",
doc => "A JSONPath string for filtering document.",
format => "s",
);
has data => (
ngs;
use Carp qw(croak);
use 5.008008;
our $VERSION = '0.03';
use URI;
use URI::QueryParam;
use JSON ();
use LWP::UserAgent;
sub new {
my ($class, %args) = @_;
croak 'Both `base_url` and `
$self->dispatch_request('get', '/api/services.json');
}
sub roles {
my $self = shift;
$self->dispatch_request('get', '/api/roles.json');
}
sub roles_in {
my ($self, $service) = @
('get', "/api/services/${service}/roles.json");
}
sub hosts {
my ($self, %options) = @_;
my $response = $self->dispatch_request('get', '/api/hosts.json');
[
grep {
if
s being installed
upon to generate its own list of dependencies (called C<MYMETA.yml> or
C<MYMETA.json>).
This module is a Module::Install plugin that generates C<MYMETA.yml> by simply
passing throug
ms (BINGOS), Ingy döt Net (INGY) and Florian Ragwitz (FLORA)
for explaining the role of C<MYMETA.json>, and helping me figure out why mine
weren't working.
=head1 COPYRIGHT AND LICENCE
This softwar
EST::MapReduce;
{
$Net::Riak::Role::REST::MapReduce::VERSION = '0.1702';
}
use Moose::Role;
use JSON;
use Data::Dumper;
sub execute_job {
my ($self, $job, $timeout) = @_;
# save existing t
int($timeout/1000));
}
$job->{timeout} = $timeout;
}
my $content = JSON::encode_json($job);
my $request = $self->new_request(
'POST', [$self->mapred_prefix]
)
success) {
die "MapReduce query failed: ".$response->status_line;
}
return JSON::decode_json($response->content);
}
1;
__END__
=pod
=head1 NAME
Net::Riak::Role::REST::MapReduce
1
);
has content_type => (
is => 'rw',
isa => 'Str',
default => 'application/json'
);
sub n_val {
my $self = shift;
if (my $val = shift) {
$self->set_property('n_
and no explicit Object content_type is given in @args, the data will be serialised and stored as JSON.
If $key is passed as C<undef> then an autogenerated key will be provided by Riak.
=item get
b OAuth2 non-web authorization token
use strict;
use warnings;
use Carp 'confess';
use autobox::JSON;
use HTTP::Tiny;
use MIME::Base64;
use Params::Validate ':all';
# for SSL and SSL CA verificatio
to_json,
});
### $res;
confess "Failed: $res->{status}/$res->{reason} / " . $res->{content}->from_json->{message}
unless $res->{success};
return $res->{content}->from_json;
lient::VERSION = '0.71';
}
#ABSTRACT: SeeAlso Linkserver Protocol Client
use Carp qw(croak);
use JSON::XS '2.0' ;
use LWP::Simple qw(get);
use URI '1.35';
use Data::Validate::URI qw(is_web_uri);
use
my $url = $self->queryURL( $identifier );
my $json = get($url);
if (defined $json) {
return SeeAlso::Response->fromJSON( $json ); # may also croak
} else {
croak("Fail
1
=head1 SYNOPSIS
$response = seealso_request ( $baseurl, $identifier );
print $response->toJSON() . "\n" if ($response);
$client = SeeAlso::Client->new( $baseurl, ShortName => "myClient" );
me eq 'rdfjson') {
$self->{formats}{'rdfjson'} = {
type => "application/rdf+json",
filter => sub { return $_[0]->toRDFJSON; },
s} if ($self->{expires});
$http .= CGI::header( %headers );
$http .= $response->toJSON($callback);
} elsif ( $format eq "debug") {
$http .= CGI::header( -status => $status,
", $self->errors) . "\n" if $self->errors;
$http .= "*/\n";
$http .= $response->toJSON($callback) . "\n";
} else { # other unAPI formats
# TODO is this properly logged?
ole::REST::Search;
{
$Net::Riak::Role::REST::Search::VERSION = '0.1702';
}
use Moose::Role;
use JSON;
#ABSTRACT: Search interface
sub search {
my $self = shift;
my %params = @_;
my $re
>code;
if ($status == 404) {
return;
}
return JSON::decode_json($http_response->content) if $params{wt} =~ /json/i;
$http_response->content;
};
sub setup_indexing {
my (
return;
}
my $precommits = JSON::decode_json($http_response->content)->{props}->{precommit};
for (@$precommits){
return JSON::decode_json($http_response->content) if $_->{mod}
ssion methods for Captive::Portal
=cut
our $VERSION = '4.10';
use Log::Log4perl qw(:easy);
use JSON qw();
use Try::Tiny;
use Digest::MD5 qw(md5_hex);
use Captive::Portal::LockHandle;
use Role::Bas
sessions_ipset>.
Session state is recorded on disc under the $SESSIONS_DIR. The session state is JSON encoded.
Example: active session
{
"STATE" : "active",
"START_TIME" : 131710
m $capo->read_session_handle($lock_handle)
Read the session file for $lock_handle and decode the JSON format into a hashref.
=cut
sub read_session_handle {
my $self = shift;
my $fh = shif
se Device::Hue::UPnP;
use Device::Hue::Light;
use LWP::UserAgent;
use LWP::Protocol::https;
use JSON::XS;
use Data::Dumper;
use Carp;
sub BUILD
{
my ($self) = @_;
$self->agent(new LWP::UserAgen
say $res->status_line
if $self->debug;
say Dumper(decode_json($res->decoded_content))
if $self->debug;
return decode_json($res->decoded_content);
} else {
say "Request failed: " . $r
ation/json');
return $self->process($self->agent->request($req));
}
sub put
{
my ($self, $uri, $data) = @_;
my $req = HTTP::Request->new('PUT', $uri);
$req->content_type('application/json');
}
sub load_config {
my $file = shift;
open(my $fh, "<", $file);
my $config = eval { JSON->new->relaxed->utf8->decode(join('',<$fh>)); };
close $fh;
return $config || { };
}
sub
};
};
} elsif ( $file =~ /\.json$/ ) {
eval {
open(my $fh, "<", $file);
my $config = JSON->new->relaxed->utf8->decode(join('',<$fh>));
=head1 INTERNAL FUNCTIONS
=head2 load_config ( $filename )
Load a configuration file (relaxed JSON format) and return a hash reference.
On error the hash reference is empty.
=head2 expand_from_co
ION = '0.1702';
}
# ABSTRACT: Allows you to build up and run a map/reduce operation on Riak
use JSON;
use Moose;
use Scalar::Util;
use Data::Dumper;
use Net::Riak::LinkPhase;
use Net::Riak::MapRed
my ($self, $bucket, $tag, $keep) = @_;
$bucket ||= '_';
$tag ||= '_';
$keep ||= JSON::false;
$self->add_phase(
Net::Riak::LinkPhase->new(
bucket => $bucket,
type => 'map',
function => $function,
keep => $options{keep} ? JSON::true : JSON::false,
arg => $options{arg} || [],
);
$self->add_phase($map_reduce);
ucePhase;
{
$Net::Riak::MapReducePhase::VERSION = '0.1702';
}
use Moose;
use Scalar::Util;
use JSON;
has type => (is => 'rw', isa => 'Str', required => 1,);
has function => (is => 'ro', i
', isa => 'Str', default => 'javascript');
has keep => (is => 'rw', isa => 'JSON::Boolean', default => sub {JSON::false});
sub to_array {
my $self = shift;
my $step_def = {
kee
e::Role;
use JSON;
use List::Util 'sum';
sub execute_job {
my ($self, $job, $timeout, $returned_phases) = @_;
$job->{timeout} = $timeout;
my $job_request = JSON::encode_json($job);
age( MapRedReq => {
request => $job_request,
content_type => 'application/json'
}, sub { push @$results, $self->decode_phase(shift) })
or
die "MapReduce que
$resp) = @_;
if (defined $resp->response && length($resp->response)) {
return JSON::decode_json($resp->response);
}
return;
}
1;
__END__
=pod
=head1 NAME
Net::Riak::Role::P
return bless $arg, $class;
}
=head2 data
This returns a data structure deserialised from the JSON part of the
response as defined by Flattr's API.
=cut
sub data {
shift->{data};
}
=head2 h