kage Mojolicious::Plugin::JSONP;
use Mojo::Base 'Mojolicious::Plugin';
our $VERSION = '0.04';
sub register {
my ($self, $app, $conf) = @_;
$app->helper(
render_jsonp => sub {
my ($sel
ethod(json => $ref, partial => 1) . ')')
: $self->render(json => $ref);
}
);
}
1;
__END__
=head1 NAME
Mojolicious::Plugin::JSONP - Render JSONP with transparent fallback to JSON
=hea
d1 SYNOPSIS
plugin JSONP => callback => 'callback_function';
get '/' => sub {
shift->render_jsonp({one => 'two'});
};
# GET request:
# ?callback_function=my_function
# Response:
Util::Accessor qw(webhooks hipchat_user_agent );
use Plack::Util;
use Plack::Request;
use JSON qw(decode_json);
use Try::Tiny;
sub call {
my($self, $env) = @_;
my $Req = Plack::Request->new
application/json') {
# warn "Not application/json Content-Type\n";
return $self->return_400();
}
my $rh;
try {
$rh = decode_json($Req->conte
nt());
} catch {
# warn "Failed to decode JSON content\n";
};
if (!$rh) {
return $self->return_400();
}
my $rc = $rh_webhooks->{$path};
nk_name' => '',
'can_credit' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ),
'can_debit' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ),
'created_at' => '2014-10-06T06:40:14.64
----------------------------------------------------------------
sub JSON {
my ($self) = @_;
return $self->{_grammar}->JSON;
}
# ---------------------------------------------------------------
mar.
=head2 pattern($self)
Return the generic Pattern for this grammar.
=head2 JSON($self)
Return the generic JSON for this grammar.
=head2 URI($self)
Return the generic URI for this grammar.
=
RT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
our $URL = 'https://rest.nexmo.com/sms/json';
sub new {
my $pkg = shift;
my %p = @_;
exists $p{_username} or die $pkg."->new requires
my ($self) = @_;
return $self->{_grammar}->pattern;
}
sub JSON {
my ($self) = @_;
return $self->{_grammar}->JSON;
}
sub URI {
my ($self) = @_;
return $self->{_grammar}->UR
gNumericLiteral grammar.
=head2 pattern($self)
Returns the pattern grammar.
=head2 JSON($self)
Returns the JSON grammar.
=head2 URI($self)
Returns the URI grammar.
=head2 spacesAny($self)
Retu
}
}
_add_aliases(qw( application/mp4 video/mp4 ));
_add_aliases(qw( application/json text/json ));
_add_aliases(qw( application/cals-1840 image/cals-1840 image/cals image/x-cals appli
:Dumper;
use DateTime;
use Email::Stuffer;
use Encode;
use File::Slurp;
use FindBin qw($Bin);
use JSON;
use Log::AutoDump;
use Plack::Handler::FCGI;
use Plack::Request;
use Template;
use Term::ANSICol
se . '/templates';
}
sub _build_filename
{
my $self = shift;
return $self->base . '/app.json';
}
=head3 base
The base directory of the application, detected using L<FindBin>.
=head3 dev
<gt>base . '/templates'>.
=head3 filename
Filename for the config file, default is C<app.json> and only JSON is currently supported.
=head3 config
The config as a hash-reference.
=head2 Instance
Service::Rakuten::API;
use 5.008005;
use strict;
use warnings;
use LWP::UserAgent;
use Mouse;
use JSON;
use URI;
our $VERSION = "0.06";
use WebService::Rakuten::API::Provider::Travel;
use WebService::
appid => __YOURAPI__
);
my $items = $rakuten->ichiba({keyword => '遊戯王',format => 'json'});
print $items->{Items}->[0]->{Item}->{itemName};
=head1 DESCRIPTION
WebService::Rakuten
l->query_form(applicationId => $context->appid,format=>$arg->{format},keyword =>$arg->{keyword});
my $res = $context->furl->get($url);
my $response = JSON::decode_json($res->decoded_content);
}
1;
ngs;
use strict;
use Carp;
use JSON::MaybeXS qw/JSON/;
use Plack::Request;
use Plack::Component;
our $VERSION = "2.001001";
$VERSION = eval $VERSION;
my $json = JSON->new->utf8->allow_blessed->conv
created web service will be a JSON-in JSON-out service. Requests to your application
are expected to have a C<Content-Type> of C<application/json; charset=UTF-8>. The JSON body
of a request will be th
e formatted into JSON as
well.
Note that if an API method does not return a hash-ref, this runner module will automatically
turn it into a hash-ref to ensure that conversion into JSON will be possibl
use strict;
my $JSON;
for ( qw/JSON::MaybeXS JSON JSON::PP/ ) {
last if $JSON = eval "use $_; '$_'";
}
$JSON or die <<'...';
ERROR: No JSON Perl modules are installed.
This Perl program is being
b' command. It requires
one of the 'JSON::MaybeXS', 'JSON' or 'JSON::PP' Perl modules, but it seems
that you have none of these installed.
Please install the 'JSON::MaybeXS' module from CPAN, and try
again.
...
{
my $data = decode_json(do {local $/; <>});
die "Unknown JSON result" unless
ref($data) =~ /^(HASH|ARRAY)$/;
walk($data, '');
};
sub walk {
my ($node, $path) = @_;
if (re
package Geo::Coder::TomTom;
use strict;
use warnings;
use Carp qw(croak);
use Encode ();
use JSON;
use LWP::UserAgent;
use URI;
our $VERSION = '0.04';
$VERSION = eval $VERSION;
sub new {
my ($
=> 'json',
%params,
);
my $res = $self->{response} = $self->ua->get($uri);
return unless $res->is_success;
# Change the content type of the response from 'application/json' s
my $content = $res->decoded_content;
return unless $content;
my $data = eval { from_json($content) };
return unless $data;
# Result is a list only if there is more than one item
ldTimeS => 0,
name => "foo",
pendingTask => bless(do{\(my $o = 0)}, "JSON::PP::Boolean"),
updatedAt => "2014-12-04T00:41:14.120Z",
},
{
create
ldTimeS => 0,
name => "bar",
pendingTask => bless(do{\(my $o = 0)}, "JSON::PP::Boolean"),
updatedAt => "2014-12-04T00:42:13.231Z",
}]
=head2 browse_index
ask_status('foo', 29734242);
B<Response:>
{
pendingTask => bless(do{\(my $o = 0)}, "JSON::PP::Boolean"),
status => "published",
}
=head2 get_keys
Retrieves global API keys
:Field::JSONmulti;
# ABSTRACT: a script tag which sets multiple vars using JSON 'data', encoded from list of perl data supplied via field for HTML::FormHandler.
$HTML::FormHandlerX::Field::JSONmulti::
VERSION = '0.004';
use Moose;
extends 'HTML::FormHandlerX::Field::JSON';
use namespace::autoclean;
use JavaScript::Minifier::XS qw();
sub wrap_data {
my $self = shift;
my @data_args = @_;
le list bit seems a bit pointless right now, why not just create and array ref and assign the one json object?
## The plan is to allow different data_key for each list element, but sensible implement
$cgi->set_header('myheader', 'whatever');
# change content type
$cgi->set_content_type('text/json');
# output HTTP headers, including added cookies, the CSRF cookie,
# and the new header
prin
GgpkZ4; path=/
# Date: Sun, 29 Jul 2012 04:08:06 GMT
# Myheader: whatever
# Content-Type: text/json; charset=ISO-8859-1
=head1 INSTALLATION
CGI::Plus can be installed with the usual routine:
pe
e JSON::XS;
our $VERSION = '0.03';
our $AUTHORITY = 'cpan:STEVAN';
use parent 'Exporter';
our @EXPORT = qw[
result_generator
create_root
create_child
];
our $FILENAME_FMT = '%s.json';
our $JSON = JSON::XS->new->utf8->pretty;
{
my $UID_SEQ = 0;
my $UID_FMT = '%04d';
sub next_UID { sprintf $UID_FMT, ++$UID_SEQ }
}
sub result_generator {
my ($uid, $parent_u
my $root_uid = next_UID;
$dir->file( sprintf $FILENAME_FMT => $root_uid )
->spew( $JSON->encode( result_generator( $root_uid ) ) );
return $root_uid;
}
sub create_child {
my $d
binmode $fh;
print $fh $tile;
=cut
use strict;
use warnings;
use LWP::UserAgent;
use URI;
use JSON;
use Math::Trig;
use constant HOST => 'cloudmade.com';
use constant DEBUG => $ENV{GEO_CLOUDMADE_
vice("geocoding/v2/find.js", [%params], 'geocoding');
return unless $content;
my $ref = from_json($content, {utf8 => 1});
my @objs;
push @objs, bless $_, 'Geo::Cloudmade::Result' foreach (@{$
vice("geocoding/v2/find.js", [%params], 'geocoding');
return unless $content;
my $ref = from_json($content, {utf8 => 1});
my @objs;
push @objs, bless $_, 'Geo::Cloudmade::Result' foreach (@{$
es->content_type;
my @compress_types = qw(
application/javascript
application/json
application/x-javascript
application/xml
);
return 1
if ($ct =~ m
a::App::Command::weaverconf::VERSION = '0.05';
use Dist::Zilla::App -command;
use Moose 0.91;
use JSON::MaybeXS ();
use List::Util qw(first);
use MooseX::Types::Moose qw(Str CodeRef);
use MooseX::Type
ar
#pod output format. The following formats are currently available:
#pod
#pod =for :list
#pod * json
#pod the default
#pod * lisp
#pod a plist of lists of plists
#pod
#pod =cut
has formatters => (
> sub { Dist::Zilla::App::CommandHelper::weaverconf::SExpGen->new->visit($_[0]) },
json => sub { JSON::MaybeXS->new(utf8 => 1, pretty => 1, canonical => 1)->encode($_[0]) },
};
}
sub abst