package Anyevent::JSONRPC::Utils;
use base qw(Exporter);
our @EXPORT_OK = qw(
delegate
do_moose
do_exporter
);
sub delegate {
my $object = shift;
croak("delegate needs a ble
ssed object as parameter") unless blessed $object;
if ( $object->isa("AnyEvent::JSONRPC::Client") ) {
# Any call is proxied to the client
return sub {
my $cv = shif
_
=head1 NAME
AnyEvent::JSONRPC::Utils - Helper functions for use with AnyEvent::JSONRPC
=head1 SYNOPSIS
# XXX being either TCP or HTTP
my $server = AnyEvent::JSONRPC::XXX::Server->new();
package WebService::ReviewBoard;
use strict;
use warnings;
use JSON::Syck;
use Data::Dumper;
use Log::Log4perl qw(:easy);
use HTTP::Request::Common;
use LWP::UserAgent;
use version; our $VERSION = q
rname";
my $password = shift or LOGCROAK "you must pass login a password";
my $json = $self->api_post(
'/api/json/accounts/login/',
[
username => $username,
password => $password
]
);
quest($request);
DEBUG "Got response:\n" . $response->as_string();
my $json;
if ( $response->is_success ) {
$json = JSON::Syck::Load( $response->decoded_content() );
}
else {
LOGDIE "Error f
my %args = @_;
my $json = $self->api_post( '/api/json/reviewrequests/new/', [%args] );
if ( !$json->{review_request} ) {
LOGDIE "create couldn't determine ID from this JSON that it got back from
server: " . Dumper $json;
}
$self->{rr} = $json->{review_request};
return $self;
}
sub fetch {
my $self = shift;
my $id = shift;
my $json = $self->api_get( '/api/json/reviewrequests/' . $
id );
$self->{rr} = $json->{review_request};
return $self;
}
sub fetch_all_from_user {
my $self = shift;
my $from_user = shift;
my $json = $self->api_get( '/api/json/reviewrequests/from/use
=> { 'a' .. 'z' },
string => 'x' x 200,
};
cmpthese( -5, $structure, qw(:core :json :yaml) );
=head1 DESCRIPTION
This module encapsulates some basic benchmarks to help you choose
name attribute:
{
name => 'JSON::XS',
deflate => sub { JSON::XS::encode_json($_[0]) }
inflate => inflate => sub { JSON::XS::decode_json($_[0]) }
}
By default Benchmark::Se
et of serialization modules
=item :core - Serialization modules included in core
=item :json - JSON modules
=item :yaml - YAML modules
=item :xml - XML formats
=back
=cut
use Bench
vent::JSONRPC::HTTP::Server;
use Moose;
extends 'AnyEvent::JSONRPC::Server';
use Carp;
use Scalar::Util 'weaken';
use AnyEvent::JSONRPC::CondVar;
use AnyEvent::HTTPD;
use JSON::XS;
use JSON::RPC:
request => sub {
my ($httpd, $req) = @_;
my $request = eval { $self->json->decode( $req->content ) };
unless (defined $request ) {
$req->respo
$response) {
$req->respond( [ 200, 'Ok', { "Content-Type" => "application/json" }, $self->json->encode( $response ) ] );
} else {
$req->respond( [ 204, 'No
yEvent::JSONRPC;
use strict;
use warnings;
use base 'Exporter';
our $VERSION = '0.15';
our @EXPORT = qw/jsonrpc_client jsonrpc_server/;
use AnyEvent::JSONRPC::TCP::Client;
use AnyEvent::JSONRPC::TC
P::Server;
sub jsonrpc_client($$) {
my ($host, $port) = @_;
AnyEvent::JSONRPC::TCP::Client->new(
host => $host,
port => $port,
);
}
sub jsonrpc_server($$) {
my ($add
ent::JSONRPC::TCP::Server->new(
address => $address,
port => $port,
);
}
1;
__END__
=encoding utf-8
=for stopwords TCP TCP-based JSONRPC RPC
=head1 NAME
AnyEvent::JSONRPC
package AnyEvent::JSONRPC::InternalHandle;
use Any::Moose;
use AnyEvent;
has cv => (
is => 'ro',
isa => 'AnyEvent::CondVar',
default => sub {
AnyEvent->condvar;
},
ite {
my ($self, $type, $json) = @_;
$self->cv->send( $json );
}
__PACKAGE__->meta->make_immutable;
__END__
=for stopwords condvar
=head1 NAME
AnyEvent::JSONRPC::InternalHandle - Handle
object used internally in
AnyEvent::JSONRPC::TCP::Server
=head1 SEE ALSO
L<AnyEvent::JSONRPC>.
=head1 AUTHOR
Peter Makholm <peter@makholm.net>
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2010 by
package AnyEvent::JSONRPC::CondVar;
use Any::Moose;
use AnyEvent;
has cv => (
is => 'ro',
isa => 'AnyEvent::CondVar',
default => sub {
AnyEvent->condvar;
},
hand
les => [qw( send recv cb )],
);
has call => (
is => 'ro',
isa => 'JSON::RPC::Common::Procedure::Call',
required => 1,
handles => [qw( is_notification )],
);
no Any::Moos
AnyEvent::JSONRPC::CondVar - Condvar object used in
AnyEvent::JSONRPC::TCP::Server and AnyEvent::JSONRPC::HTTP::Server
=head1 SEE ALSO
L<AnyEvent::JSONRPC::TCP::Server> and L<AnyEvent::JSONRPC::HTTP
:ImgData version 0.0.3
=head1 SYNOPSIS
use MyWebApp;
use CGI::Application::Plugin::JSON qw(to_json);
use CGI::Application::Plugin::AJAXUpload;
use Data::FormValidator::Filters::ImgDa
ur project. For example, to build in the "dev" context,
there must be a F<dev.yml> file (or F<dev.json> or some other format supported
by L<Config::Any>) in the F<conf/> or F<etc/> directory of your p
ill be used.
=head3 test_env
./Build db --test_env CATALYST_DEBUG=0 CATALYST_CONFIG=conf/test.json
Optional hash reference of environment variables to set for the lifetime of
C<./Build test>. Thi
module_name => 'MyApp',
db_config_key => 'dbi',
replace_config => 'conf/dev.json',
)->create_build_script;
Set to a string or regular expression (using C<qr//>) and, the C<mod
ile);
};
if ($@) {
carp $@;
return $c->to_json({status=> 'Internal Error'});
}
return $r;
}
);
return;
$dfv_profile = shift;
my $httpdocs_dir = $self->ajax_upload_httpdocs;
return $self->to_json({status => 'No document root specified'})
if not defined $httpdocs_dir;
my $full_upl
');
return $self->to_json({status=>'No file handle obtained'})
if !defined $lightweight_fh;
my $fh = $lightweight_fh->handle;
return $self->to_json({status => 'No file han
Ix::Class ':all';
use CGI::Application::Plugin::Redirect;
use Net::Lujoyglamour qw(is_valid);
use JSON;
sub cgiapp_init {
my $self = shift;
my (%args ) = @_;
croak "No DSN" if !$args{'PA
eq 'JSON' ) {
my $json;
if ($new_short_url ne '') {
$json = to_json( { shortu => $self->param('domain')."/".$new_short_url,
longu => $long_url} );
} else {
$json = to_json( {m
sg => $@} );
}
$self->header_props(-type=>'application/json');
return $json;
}
}
sub redirect_url {
my $self = shift;
my $url = $self->param('url');
my $long_url = $self->s
nstraints;
use MooseX::StrictConstructor;
require HTTP::Request;
require HTTP::Response;
require JSON::XS;
require LWP::UserAgent;
use version; our $VERSION = qv('0.0.2');
# DEFAULT VALUES
Readonly
) }
# JSON
has '_json' => (
is => 'ro',
isa => duck_type( 'JSON', [ qw( new decode_json ) ] ),
lazy_build => 1,
required => 1,
);
sub _build__json { return( JSON::XS->n
Accept => 'application/json' );
# send it
my( $response ) = $self->_ua->request( $request );
# what did we get?
if ( $response->is_success ) {
my( $json ) = $response->decode
s request
use Moose;
use Moose::Util::TypeConstraints;
use URI;
use LWP::UserAgent;
use JSON qw{ decode_json };
has 'ihq' => (
is => 'rw',
isa => 'Str',
required => 1,
);
ha
t => 'desc',
);
sub execute {
my $self = shift;
my $api_url = 'http://isohunt.com/js/json.php';
my %parametres = (
'ihq' => $self->ihq (),
'start' => $self->start()
t' );
my $json = $ua->get($uri)->decoded_content();
my $json_decoded = decode_json($json);
my $image = Net::isoHunt::Response::Image->new( {
'title' => $json_decoded->{'i
get rid of "value computed is not used" warnings */
#define IGNORE_RV(x) (void)(x)
static SV *
vjson_encode_error(self_context * ctx, const char * file, int line_num, const char * fmt, va_list *ap_p
* error = newSVpv("", 0);
bool junk = 0;
HV * error_data = Nullhv;
sv_setpvf(error, "JSON::DWIW v%s - ", MOD_VERSION);
sv_vcatpvfn(error, fmt, strlen(fmt), ap_ptr, (SV **)0, 0, &junk
, 7, newSVpvf("%s", MOD_VERSION), 0));
return error;
}
#if defined(JSONEVT_HAVE_FULL_VARIADIC_MACROS)
static SV *
json_encode_error(self_context * ctx, const char * file, int line_num, const c
D_COMMON_H
#include "DWIW.h"
#include "libjsonevt/int_defs.h"
#include "libjsonevt/utf8.h"
#define kCommasAreWhitespace 1
/* a single set of flags for json_context and self_context */
#define kUseE
ine kBadCharError 0
#define kBadCharConvert 1
#define kBadCharPassThrough 2
/* for converting to JSON */
typedef struct {
SV * error;
SV * error_data;
int bare_keys;
UV bad_char_polic
mail::MIME::Kit::Renderer::TT>
=head3 L<Email::Sender>
=head3 L<Function::Parameters>
=head3 L<JSON>
=head3 L<List::AllUtils>
=head3 L<Method::Signatures::Simple>
=head3 L<Moose>
=head3 L<Moose
e ) = @_;
if ( $type ne 'jsontext' ) {
confess q{the only valid value is 'jsontext'};
}
},
);
has [
qw{
key
jsonp
}
] => (
is => 'r
is C<jsontext>. Responds with mime-type text/json, if set.
=head2 C<key>
Accepts a key and validates this request to a specific application.
=head2 C<jsonp>
If set, the response returns JSON with
Padding instead of standard JSON.
=head1 AUTHOR
Alan Haggai Alavi <alanhaggai@alanhaggai.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Alan Haggai Alavi.
This is free
s
use Moose;
use Moose::Util::TypeConstraints;
with 'Net::StackExchange::Role::Response';
has 'json' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'answers' => (
et::StackExchange::Answers]',
writer => 'set_answers',
reader => 'get_answers',
);
has '_json_decoded' => (
is => 'ro',
isa => 'HashRef',
required => 1,
trigger =>
_object {
my $self = shift;
my $json = $self->json();
my $json_decoded = $self->_json_decoded();
my @answers;
for my $answer_ref ( @{ $json_decoded->{'answers'} } ) {
my
Don
*/
#ifndef JSONEVT_PLUS_PLUS_H
#define JSONEVT_PLUS_PLUS_H
#include <jsonevt.h>
#include <vector>
#include <string>
class JSONEvt {
public:
JSONEvt() { };
~JSONEvt() { };
s
_strings(const std::string& json_str,
std::vector<std::string>& result, std::string& err_out);
static int parse_list_of_strings(const char *json_str, uint json_str_size,
std::vect