t::CouchDB::Stream;
use strict;
use warnings;
use URI;
use AnyEvent::HTTP;
use Scalar::Util;
use JSON;
use Try::Tiny;
use MIME::Base64;
our $VERSION = '0.02';
sub new {
my $class = shift
sub { };
my $headers = delete $args{headers}
|| { 'Content-Type' => 'application/json' };
my $include_docs = delete $args{include_docs};
my $uri = URI->new($server);
$uri
e, $json ) = @_;
$set_timeout->();
if ($json) {
try {
$on_change->(JSON::decode_json($json));
ders', 'body' ],
},
'AnyEvent::CouchDB::Exception::JSONError' => {
isa => 'AnyEvent::CouchDB::Exception',
description => 'JSON decoding error',
},
'AnyEvent::CouchDB::Exception
# handle an HTTP error
}
when (ref eq 'AnyEvent::CouchDB::Exception::JSONError') {
# handle a JSON decoding error
}
default {
$_->show_trace(1);
warn "$_";
chDB::Exception for HTTP errors
=item AnyEvent::CouchDB::Exception::JSONError
A subclass of AnyEvent::CouchDB::Exception for JSON decoding errors
=back
=head1 API
This module provides the follow
014;
use Moo;
use Heap::Elem::Str qw( StrElem );
use Heap::Fibonacci ();
use JSON::MaybeXS qw( decode_json encode_json );
use List::Util 1.34 qw/ any none /;
use Path::Tiny qw/ path /;
use WWW::
_url || $base_url );
my $state =
+( $state_fn && ( -e $state_fn ) )
? decode_json( path($state_fn)->slurp_utf8 )
: {
stack => scalar( Heap::Fibonacci->n
rec);
if ($state_fn)
{
path($state_fn)->spew_utf8( encode_json($state) );
}
my $from = ( $encountered_urls->{$dest_url} // "START" );
use System::Introspector::Gatherer;
use Object::Remote::Future qw( await_all );
use JSON::Diffable qw( encode_json );
has config => (is => 'ro', required => 1);
has root => (is => 'ro', required =>
my @files;
for my $class (sort keys %$gathered) {
my $file = sprintf '%s.json', join '/',
map lc, map {
s{([a-z0-9])([A-Z])}{${1}_${2}}g;
storage->file($file);
$self->_log("Writing $full_path");
print $fh encode_json($gathered->{$class});
push @files, $full_path;
}
$self->_cleanup($sto
ault update method
=cut
sub update{
my $self = shift;
return $self->render(status => 405, json => {message => 'You can only update your own profile!!!'} )
if ( !defined $self->param('id')
t of probes
on the remote system that gather specific information. Gathered results
are stored in JSON format.
=head1 AUTHOR
phaylon - Robert Sedlacek (cpan:PHAYLON) <r.sedlacek@shadowcat.co.uk>
=
model = RDF::Trine::Model->temporary_model;
my $content_type_mapping = {
'application/json' => sub {$self->export_to_hash(%opts)},
'application/rdf+xml' => sub {$self->export_to_st
';
use JSON;
use AnyEvent::HTTP;
use AnyEvent::CouchDB::Exceptions;
use Data::Dump::Streamer;
use URI::Escape qw( uri_escape uri_escape_utf8 );
use IO::All;
use MIME::Base64;
our $default_json;
# ma
:cvcb;
*default_json = *AnyEvent::CouchDB::default_json;
*_build_headers = *AnyEvent::CouchDB::_build_headers;
our $query = sub {
my $options = shift;
my $json = $default_json;
my @buf;
$name eq 'startkey' || $name eq 'endkey') {
$value = ref($value)
? uri_escape($json->encode($value))
: (defined $value)
? uri_escape_utf8(qq{"$value"})
=head1 DESCRIPTION
Clustericious::Config reads configuration files which are Mojo::Template's
of JSON or YAML files. There should generally be an entry for
'url', which may be used by either a clien
ding on
how this node in the cluster is being used.
After rendering the template and parsing the JSON, the resulting
object may be called using method calls or treated as hashes.
Config files are lo
re may be overridden.
YAML config files must begin with "---", otherwise they are interpreted
as JSON.
Clustericious::Config provides a "get_password" function which will prompt
for a password if it
ory';
return $obj;
}
sub show{
my $self = shift;
return $self->render(status => 405, json => {message => 'You can only see your own categories!!!'} )
if ( !defined $self->param('id')
urn $self->render_json( $result );
}
=head update
sample of overriding a default update method
=cut
sub update{
my $self = shift;
return $self->render(status => 405, json => {message => 'Y
};
}
return $self->render_not_found() if scalar @$result == 0 ;
return $self->render_json( $result );
}
1;
__END__
=pod
=head1 NAME
ExpenseTracker::Controllers::Category - Controll
package AnyEvent::CouchDB;
use strict;
use warnings;
our $VERSION = '1.30';
use JSON;
use AnyEvent::HTTP;
use AnyEvent::CouchDB::Database;
use AnyEvent::CouchDB::Exceptions;
use URI;
use URI::Escape
"AnyEvent::CouchDB::Exception::HTTPError";
our $JSONError = "AnyEvent::CouchDB::Exception::JSONError";
# default JSON encoder
our $default_json = JSON->new->utf8;
# arbitrary uri support
sub _build
}
elsif ( !exists $headers->{'Content-Type'} ) {
$headers->{'Content-Type'} = 'application/json';
}
if ( exists $self->{http_auth} ) {
$headers->{'Authorization'} = $self->{http_auth};
package Net::GoogleDrive;
use common::sense;
use JSON;
use Mouse;
use LWP::UserAgent;
use HTTP::Request::Common;
use URI;
=head1 NAME
Net::GoogleDrive - A Google Drive API interface
=head1 VERSION
->ua();
my $res = $ua->request($req);
if ($res->is_success()) {
my $token = JSON::from_json($res->content());
$self->access_token($token->{access_token});
print "Got
nt wrong: ".$res->status_line();
}
}
=head2 files
This returns a files Resource object from JSON.
=cut
sub files
{
my $self = shift;
my $req = HTTP::Request->new(
GET => 'http
b Command Tools
use Carp;
use Moose;
use Net::GitHub;
use Term::ReadKey;
use Term::ReadLine;
use JSON::XS;
use IPC::Cmd qw/can_run/;
our $VERSION = '1.0.1';
has 'term' => (
is => 'rw',
c2(@args);
# o.blob return plain text
if ( ref $result ) {
$result = JSON::XS->new->utf8->pretty->encode($result);
}
$self->print($result);
};
if
package Bio::KBase::InvocationService::Client;
use JSON::RPC::Client;
use strict;
use Data::Dumper;
use URI;
use Bio::KBase::Exceptions;
=head1 NAME
Bio::KBase::InvocationService::Client
=head1 DE
rams => \@args,
});
if ($result) {
if ($result->is_error) {
Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
code => $result->content->{code},
rams => \@args,
});
if ($result) {
if ($result->is_error) {
Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
code => $result->content->{code},
JSON::RPC::Client;
use strict;
use Data::Dumper;
use URI;
=head1 NAME
Bio::KBase::IDServer::Client
=head1 DESCRIPTION
=cut
sub new
{
my($class, $url) = @_;
my $self = {
client => JSON
;
use Lingua::EN::Inflect::Number;
our $RESOURCE_DEBUG = 0;
my $content_types = {
json => 'application/json',
yml => 'text/x-yaml',
xml => 'application/xml',
};
my %routes;
# thanks
(
($conf && exists $conf->{serializers})
? $conf->{serializers}
: { 'json' => 'JSON',
'yml' => 'YAML',
'xml' => 'XML',
'dump' => 'Dumper',
User->find(params->{user_id});
...
}
# curl http://mywebservice/user/42.json
{ "id": 42, "name": "John Foo", email: "john.foo@example.com"}
# curl http://mywebservic
pod
=head3 C<to_json($data)>
Returns the JSON representation of C<$data> (arbitrary
datastructure -- but not objects). See http://www.json.org/ or
http://en.wikipedia.org/wiki/JSON for details. In
to_json {
my $self = shift;
my $data = shift;
return 'null' unless defined $data;
my $type = reftype($data);
unless (defined($type)) {
return $self->_escape_json_str
n(',', map { $self->to_json($_) } @$data) . ']';
}
elsif ($type eq 'HASH') {
my @keys = sort keys %$data;
return '{' . join(',', map { $self->_escape_json_str($_) . ':'
package Bio::KBase::CDMI::Client;
use JSON::RPC::Client;
use strict;
use Data::Dumper;
use URI;
use Bio::KBase::Exceptions;
=head1 NAME
Bio::KBase::CDMI::Client
=head1 DESCRIPTION
=cut
sub new
rams => \@args,
});
if ($result) {
if ($result->is_error) {
Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
code => $result->content->{code},
rams => \@args,
});
if ($result) {
if ($result->is_error) {
Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
code => $result->content->{code},
-sapObj} = SAPserver->new();
}
else
{
use JSON::XS;
open(CONTIGS,"<$g") || die "$g is not a file that can be opened";
my $json = JSON::XS->new;
my $input_genome;
local $/;
undef $/;
my $input_genome_txt = <CONTIGS>;
$input_genome = $json->decode($input_genome_txt);
my $tmp = $input_genome->{contigs};
my @raw_contigs = map { [$_->{id},'',$_->{dna
package Bio::KBase::GenomeAnnotation::Client;
use JSON::RPC::Client;
use strict;
use Data::Dumper;
use URI;
use Bio::KBase::Exceptions;
=head1 NAME
Bio::KBase::GenomeAnnotation::Client
=head1 DESC
rams => \@args,
});
if ($result) {
if ($result->is_error) {
Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
code => $result->content->{code},
rams => \@args,
});
if ($result) {
if ($result->is_error) {
Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
code => $result->content->{code},