package Plack::Middleware::SocketIO::Connection;
use strict;
use warnings;
use JSON ();
use Try::Tiny;
sub new {
my $class = shift;
my $self = {@_};
bless $self, $class;
$self->{o
$self = shift;
my ($message) = @_;
if (ref $message) {
$message = '~j~' . JSON::encode_json($message);
}
return '~m~' . length($message) . '~m~' . $message;
}
sub _generate
.*)/) {
my $json;
try {
$json = JSON::decode_json($1);
};
return $json if defined $json;
return $
package Plack::Middleware::SocketIO::Base;
use strict;
use warnings;
use JSON ();
use Encode ();
use Try::Tiny;
use Scalar::Util qw(weaken);
use Plack::Request;
use Plack::Middleware::SocketIO::H
er = Router::Simple->new();
$router->connect('/', { controller => 'JSONRPC', action => 'call' }, {on_match => \&is_called_json_rpc});
$router->connect('/', { controller => 'Root', action => 'i
->{action}, $res);
} else {
return [ 404, [], ['not found'] ];
}
}
sub is_called_json_rpc {
my ($env, $match) = @_;
my $req = App::Donburi::Web::Request->new($env);
return
age App::SD::Server::Static;
use Any::Moose;
extends 'App::SD::Server';
use Params::Validate;
use JSON;
sub log_request { }
sub send_content {
my $self = shift;
my %args = validate( @_, { co
=> 0, static => 0 } );
if ( $args{'encode_as'} && $args{'encode_as'} eq 'json' ) {
$args{'content'} = to_json( $args{'content'} );
}
return $args{'content'};
}
sub _send_redirec
package App::Donburi::Web::C::JSONRPC;
use strict;
use warnings;
use parent 'App::Donburi::Web::C';
use JSON;
use App::Donburi::Util;
sub do_call {
my $self = shift;
my $method = $self->re
q->param('method');
my $params = JSON->new->utf8->decode($self->req->param('params') || {});
my $text = $params->{text};
my $channel = $params->{channel};
unless (
$method eq
error?
return [
500,
[ 'Content-Type' => 'application/json' ],
[ JSON->new->utf8->encode({ message => 'internal server error', code => 000 }) ]
];
:Dumper;
use URI::Escape;
use HTTP::Request::Common;
use HTTP::Response;
use LWP::UserAgent;
use JSON;
use utf8;
# ABSTRACT: API para enviar SMS através da NSMS (http://www.nsms.com.br/)
our $VERSI
=> 1,
default => sub {
my $self = shift;
join( '/', $self->baseurl, 'get', 'json' )
. '?to=55'
. $self->to
. '&content='
. uri_esc
> 'Bool',
default => 0
);
sub _json_to_struct {
my ( $self, $ret ) = @_;
$ret = $ret->content if ref($ret) eq 'HTTP::Response';
my $st = decode_json($ret);
print Dumper($st) if $s
package PocketIO::Transport::Base;
use strict;
use warnings;
use JSON ();
use Encode ();
use Try::Tiny;
use Scalar::Util qw(weaken);
use Plack::Request;
use PocketIO::Handle;
use PocketIO::Pool;
package PocketIO::Connection;
use strict;
use warnings;
use AnyEvent;
use JSON ();
use Encode ();
use Try::Tiny;
use PocketIO::Pool;
use constant DEBUG => $ENV{POCKETIO_CONNECTION_DEBUG};
sub new
$self = shift;
my ($message) = @_;
if (ref $message) {
$message = '~j~' . JSON::encode_json($message);
}
else {
$message = Encode::encode('UTF-8', $message);
}
my $json;
try {
$json = JSON::decode_json(Encode::encode('UTF-8', $1));
};
return $json if defined $json;
e;
BEGIN { extends 'Catalyst::Controller' };
with 'CatalystX::Controller::ExtJS::Direct';
use JSON::XS;
sub add : Chained('/') : Path : CaptureArgs(1) {
my($self,$c, $arg) = @_;
$c->stash->
->body( $c->stash->{add} + $arg );
}
sub echo : Local : Direct : DirectArgs(1) {
my ($self, $c) = @_;
$c->res->content_type('application/json');
$c->res->body(encode_json($c->req->data));
}
if(!response.responseText.match(/ERROR: /)){
file_id = Ext.util.JSON.decode(response.responseText).success;
Ext.fly(file_upload_box).remove();
Ext.fly(file_
the JSON
try{
file_id = Ext.util.JSON.decode(response.responseText).success;
Ext.fly(file_control).insertHtml('afterBegin', '$error_image'+file_id);
}catch(e){
//JSON deco
if(!response.responseText.match(/ERROR: /)){
file_id = Ext.util.JSON.decode(response.responseText).success;
Ext.fly(file_upload_box).remove();
Ext.f
package WWW::ProximoBus;
use strict;
use warnings;
use Any::Moose;
use Carp;
use JSON;
use LWP::UserAgent;
our $VERSION = '0.01';
has 'api_host' => ( is => 'rw', default => 'proximobus.appspot.com
_for($path);
my $res = $self->ua->get($uri);
if ($res->is_success) {
return JSON::decode_json($res->content);
}
else {
die "ProximoBus HTTP error " . $res->code . ": "
gency.json";
return $self->get($path);
}
sub routes {
my $self = shift;
my ($agency) = @_;
croak "need an agency" unless ($agency);
my $path = "/agencies/$agency/routes.json";
ocation
));
sub _new {
my $class = shift;
my $json = shift;
my $self = {};
bless $self, $class;
$self->image_location($json->{'image_location'});
return $self;
}
=head1 ME
hine::DB::VERSION = '0.18';
}
use strict;
use warnings;
use Carp qw/croak confess/;
use DBI;
use JSON;
use constant QUEUE_PREFIX => 'jm:';
use constant RESPONSE_PREFIX => 'jmr:';
sub new {
my (
$args{schema} ||= 'jobmachine';
return bless \%args, $class;
}
sub json {
my ($self) = @_;
return $self->{json} ||= JSON->new->allow_nonref;
}
sub listen {
my ($self, %args) = @_;
my $queue
;
my $class = $self->fetch_class($queue);
$self->{current_table} = 'task';
my $frozen = $self->json->encode($data);
my $sql = qq{
INSERT INTO
"$self->{schema}".$self->{current_table}
(clas
> 'root/static/images',
image_chooser_url => '/static/images'
}
);
# use a JSON view
# output is available at /images
1;
Example at L<http://www.extjs.com/deploy/dev/
/chooser.html>.
=head1 DESCRIPTION
This module generates an object which can be serialized to a json string. The ImageChooser class of ExtJS expects
the data in this way.
You can even look in subdi
e of mine, and remove the exception origin
# from the end of the string as it will mess up the JSON
if($@ =~ /(ERROR:.*)at \/.*/){
# Exception is mine, handle it
$c->stash->{'success'} = '"
TML::Mason
HTML::Parser
IO::All
IO::Stringy
Image::Info
Imager
Iterator
Iterator::Util
JSON
JSON::XS
Lingua::EN::Inflect
Lingua::Strfname
List::MoreUtils
List::Util
Locale::Maketext
Luc
:Deep
Test::Differences
Test::Exception
Test::File
Test::File::Contents
Test::Harness
Test::JSON
Test::MockModule
Test::More
Test::NoWarnings
Test::Number::Delta
Test::Output
Test::Perl::C
use base 'Bash::Completion::Plugin';
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use JSON;
use Bash::Completion::Utils qw( command_in_path );
sub should_activate {
my @commands = qw
= $ua->request(
POST 'http://api.metacpan.org/release/_search',
Content => encode_json(
{ size => 1000,
fields => ['distribution'],
sort
al {
my $json = decode_json( $res->content );
$req->candidates('') unless ( $json->{hits} );
my @candidates;
my $exact_match = 0;
for ( @{ $json->{hits}->{hits}
no strict 'refs';
*{"main::getlinkstats"} = *{"WWW::Shorten::Googl::getlinkstats"};
}
use JSON::Any;
use Carp;
use constant API_URL => 'https://www.googleapis.com/urlshortener/v1/url';
use co
my $url = shift or croak 'No URL passed to makeashorterlink';
my $json = JSON::Any->new;
my $content = $json->objToJson( { longUrl => $url, } );
my $res = _request( 'post', API_URL, Con
on/json';
my $resp = $ua->$method( $url, %headers, @args );
die "Request failed - " . $resp->status_line unless $resp->is_success;
my $json = JSON::Any->new;
my $obj = $json->jsonTo
;
my $json = shift;
my $self = {};
if (defined $json->{'errors'}) { croak join("; ", map {s/\.*$//; $_} @{$json->{'errors'}}); }
bless $self, $class;
$self->imdb($json->{'imdb'}
$self->title($json->{'title'});
$self->year($json->{'year'});
$self->page($json->{'page'});
$self->posters( [ map { WebService::MoviePosterDB::Poster->_new($_) } @{$json->{'posters'}} ]
g'>, C<1.32>, and etc, to describe the value
range of data table field.
=item *
It can generate JSON or SQL insert statements to ease importing to RDMBSes like MySQL/PostgreSQL.
=back
Below is a v
/data/departments.schema.json
Wrote ./data/departments.rows.json
Wrote ./data/employees.schema.json
Wrote ./data/employees.rows.json
We see that it generates two F<.json> data files for the C<d
ctively. For example, the F<data/emplyees.rows.json> file on my machine resulting from
a particular run looks like this:
$ cat data/employees.rows.json
[["id","name","age","tel","birthday","heigh