'rw', isa => 'Bool', default => 1 );
has 'data_format' => ( is => 'ro', isa => 'Str', default => 'json' );
has 'debug' => ( is => 'rw', isa => 'Bool', default => 0 );
has 'userid' => ( is => 'ro', isa
package WebService::Buxfer::Response;
use Moose;
use JSON::XS ();
use Carp qw(carp);
has 'raw_response' => (
is => 'ro',
isa => 'Object',
handles => [ qw( status_code status_mes
t = $self->raw_response->content;
return {} unless $content;
my $obj;
return JSON::XS::decode_json( $content );
}
sub ok {
my $self = shift;
my $status = $self->buxfer_status;
er::Response->new(
$lwp_ua->request(
GET 'https://www.buxfer.com/transactions.json?token=XXX'
)
);
exit 1 unless $response->ok;
foreach ( $response->conte
lication;
use strict;
use warnings;
use version; our $VERSION = qv('0.01');
use Class::Std;
use JSON::XS 2.01;
my %flow_control_of :ATTR(:name<flow_control> :default<()>);
my %viewstate_of :ATTR
flow_control && $viewstate ) {
$flow_control->restore_state_recursive(
decode_json(
$viewstate_of{ident $self} = $viewstate
)
);
}
retu
= $flow_control->get_state_recursive();
if ( ref $viewstate ) {
$viewstate = encode_json($viewstate);
}
return $viewstate_of{$ident} = $viewstate;
}
1;
__END__
=pod
=head1 N
package DB::CouchDB;
use warnings;
use strict;
use JSON -convert_blessed_universally;
use LWP::UserAgent;
use URI;
use Encode;
$DB::CouchDB::VERSION = 0.2;
=head1 NAME
DB::CouchDB - A low leve
_;
$opts{port} = 5984
if (!exists $opts{port});
my $obj = {%opts};
$obj->{json} = JSON->new();
return bless $obj, $class;
}
=head2 Accessors
=over 4
=item *
host - host na
=item *
json - the JSON object for serialization
=back
=cut
sub host {
return shift->{host};
}
sub port {
return shift->{port};
}
sub db {
return shift->{db};
}
sub json {
my
te db response is: ", $/, $conn->json()->encode($resp), $/;
my $resp = $conn->create_doc('mb_test', {foo => 'bar'});
print "create doc response is: ", $/, $conn->json()->encode($resp), $/;
my $respOb
", $/, $conn->json()->encode($resp), $/;
$respObj = $resp;
$respObj->{bleh} = 'blah';
$resp = $conn->update_doc('mb_test', $id, $respObj);
print "update response is: ", $/, $conn->json()->encode($re
al get doc response is: ", $/, $conn->json()->encode($resp), $/;
my $rev = $resp->{_rev};
$resp = $conn->all_dbs();
print "all dbs response is: ", $/, $conn->json()->encode($resp), $/;
$resp = $conn-
schema_from_db();
}
}
=head2 load_schema_from_script($script)
loads a CouchDB Schema from a json script file. This is sort of like the DDL
in a SQL DB only its essentially just a list of _design
hema_from_script {
my $self = shift;
my $script = shift;
$self->schema($self->server->json->decode($script));
return $self;
}
=head2 load_schema_from_db()
Loads a CouchDB Schema from
et_doc($docname);
push @docs, $doc;
}
$db->json->pretty([$pretty]);
my $script = $db->json->encode(\@docs);
$db->json->pretty([undef]);
return $script;
}
sub _mk_view_acce
ot::Pluggable::Module::PathtraqPageCounter;
use strict;
use warnings;
use Readonly;
use URI;
use JSON;
use LWP::UserAgent;
use Data::Dumper;
use base qw(Bot::BasicBot::Pluggable::Module);
Readonly
( $self, $url ) = @_;
my $res = $self->_get($url);
my $content = $res->is_success ? from_json( $res->content ) : undef;
return $content->{count} if $content;
}
sub _get {
my ( $self,
my $uri = URI->new( $API_BASE_URL . '/page_counter' );
my $params = {};
$params->{api} = 'json';
$params->{url} = $url;
$uri->query_form($params);
$uri;
}
sub _create_reply_messag
r(), $/;
return;
}
VIEW: while (my $doc = $test->next()) {
print $server->json->encode($doc);
my $stop;
$self->get_response('Continue viewing results?[Y/n]', su
Class::Accessor::Fast);
__PACKAGE__->mk_accessors(qw(error));
use WWW::HatenaLogin;
use URI;
use JSON::Syck 'Load';
use Scalar::Util qw(blessed);
use Time::HiRes qw(sleep);
sub new {
my ($class,
}
my $count = exists($data->{count}) ? $data->{count} : 0;
my $res = $self->_entries_json($data->{uri});
return undef unless $res;
if ($count) {
my $wait = exists($opt->{
f->_star_add_json($data);
return undef unless $res;
sleep($wait);
$callback->($cur, $max) if $callback;
}
$res = $self->_entries_json($data->{uri}
thod(s) to add to your own controller to ForumCodify some text and return
the marked up HTML in a JSON response.
This is useful as part of a solution to provide in-page edit-preview toggling
(via YUI
et sw=4 sr sta
use strict;
use warnings;
use parent 'Catalyst::Controller';
use JSON::Any;
use HTML::ForumCode;
sub preview : Local {
my ($self, $c) = @_;
my
my $msg_source = $c->request->param('msg_source');
my $j = JSON::Any->new;
my $json = $j->to_json(
{
'formatted' =>
$tt_forum-
$msg_source
)
}
);
$c->response->body( $json );
return;
}
1;
=head1 DESCRIPTION
This recipe provides a L<Catalyst> controll
base qw/Net::Twitter/;
use URI::Escape;
our $VERSION = '0.11';
#http://search.twitter.com/search.json?q=<query>
sub search {
my $self = shift;
my $query = shift;
my $params = shift || {}
de = $params->{'since'} || undef;
#build URL
my $url = 'http://search.twitter.com/search.json?q=' . URI::Escape::uri_escape($query) .'&page='. $page;
$url .= '&lang=' . URI::Escape::uri_e
nless $req->is_success;
return [] if $req->content eq 'null';
#decode the json
my $res = JSON::Any->jsonToObj($req->content) ;
return $res->{'results'};
}
1;
=head1 NAME
Net::Tw
=cut
use Test::More qw(no_plan);
use Test::Group;
use File::Slurp;
use App::CamelPKI::Error;
use JSON;
my $certificate = <<"CERTIFICATE";
-----BEGIN CERTIFICATE-----
MIICsDCCAhmgAwIBAgIJANdqtXzdPS/1
#TODO: verifier pourquoi ca marche pas
# try {
# App::CamelPKI::Certificate->parse(JSON::from_json("null"));
# fail;
# } catch App::CamelPKI::Error::Internal with {
# pass;
App::CamelPKI::Error::Internal("ABSTRACT_METHOD")
if ($class eq __PACKAGE__);
# Some JSON objects stringify to undef! In this case, Perl
# converts them into the null string, with a
e JSON;
sub Bogus::Template::list_keys { qw(foo bar main) };
my %got = Bogus::Template->App::CamelPKI::CertTemplate::normalize_opts
(bar => [ qw( ba pa pa ) ],
foo => JSON::
from_json('"yourself"'),
main => "screen",
turn => "on");
is_deeply(\%got, {
foo => "yourself",
bar => [qw(ba pa pa)],
given certificate template.
Actions with name ending by C<_pem> don't use L<App::CamelPKI::View::JSON>,
but rather transmit directly their data in text/plain; this enables
operation with very basic c
c->res->status(500);
$c->stash->{json} = {
error => $last_error,
};
$c->error(0);
}
else {
$c->stash->{json} = {
result => $self->result
|| '',
error => $self->error || '',
};
}
$c->forward( $c->view('JSON') );
}
=head1 AUTHOR
Daisuke Murase
=head1 LICENSE
This library is free software, you can redist
SION = '0.01';
use POE qw/
Wheel::FollowTail
Component::Client::HTTPDeferred
/;
use JSON::XS ();
use HTTP::Request::Common;
use Fcntl ':flock';
has hist_file => (
is => 'rw',
Client::HTTPDeferred->new;
},
);
has json_driver => (
is => 'rw',
isa => 'JSON::XS',
lazy => 1,
default => sub {
JSON::XS->new->latin1;
},
);
has poll_del
session, $data) = @_;
my $json = $self->json_driver->decode($data);
if ($json->{error}) {
warn 'api poll error: '. $json->{error};
}
elsif ($json->{result}) {
$self->{
lated).
=head2 json_helloworld
Accepts a JSON parameter which contains an associative table with keys
"nom" (meaning last name in French) and "prenom" (first name), and
returns a JSON parameter whic
For the fame of it,
"Bonjour" means "Hello" in French.)
=cut
sub json_helloworld : Local : ActionClass("+App::CamelPKI::Action::JSON") {
my ($self, $c, $input) = @_;
$c->stash->{salutation}
l that the HTTP/S client is wielding (deduced from its client
certificate in L<App::CamelPKI>). A JSON request is not needed, allowing
the use of C<curl> in command-line mode for testing purposes.
=c
plate controller> is an entry point into Camel-PKI : it consists
of the code that responds to the JSON-RPC requests for issuing or
revoking certificates. Other user-initiated Certification Authority
d2 certifyJSON($reqdetails) : Local : ActionClass("+App::CamelPKI::Action::JSON")
Requests the issuance of a number of certificates in this template
family. $reqdetails (passed as the JSON-RPC POST
the same call to
I<certify> throws an exception.
The response is transmitted as an C<application/json> HTTP document,
with the following structure (again in Perl syntax):
{
keys => [