use Try::Tiny;
use Carp;
use LWP;
use HTTP::Request::Common;
use Encode qw();
use Data::Dump;
use JSON::PP;
=head1 NAME
Business::Tax::Avalara - An interface to Avalara's REST webservice
=head1 SY
EST-based sales tax webservice.
It takes in a perl hash of data to send to Avalara, generates the JSON, fetches a response,
and converts that back into a perl hash structure.
This module only support
nd 'unique_key' in the get_tax() call.
If debug is set to a true value, it will dump out the raw json messages being sent to
and coming back from Avalara.
Returns a Business::Tax::Avalara object.
=
ode';
has user_info => 1;
has user_info_url => 'https://api.fitbit.com/1/user/-/profile.json';
sub moniker { 'fitbit' }
1;
=pod
=encoding UTF-8
=head1 NAME
Mojolicious::Plugin::Web::Au
package PubNub::PubSub;
use strict;
use warnings;
use v5.10;
use Carp;
use Mojo::JSON qw/encode_json/;
use Mojo::UserAgent;
use Mojo::Util qw/url_escape/;
use PubNub::PubSub::Message;
our $VERSION
";
return map {
my $json = $_->json;
my $uri = Mojo::URL->new($self->{web_host} . qq~/publish/$pub_key/$sub_key/0/$channel/0/~ . url_escape($json));
$uri->query($_->query
my $json = $tx->res->json;
my @cb_args = $params{raw_msg} ? ($json) : (@{$json->[0]});
my $rtn = $callback ? $callback->(@cb_args) : 1;
return unless $rtn;
$timetoken = $json->[1];
:Fitbit::Response;
$WebService::Fitbit::Response::VERSION = '0.000001';
use Moo;
use JSON::MaybeXS qw( decode_json );
use Types::Standard qw( Bool InstanceOf Maybe HashRef );
has content => (
is
my $self = shift;
my $content = $self->raw->decoded_content;
return $content ? decode_json($content) : undef;
}
sub _build_success {
my $self = shift;
return $self->raw->is_succes
item raw
An L<HTTP::Response> object.
=back
=head1 METHODS
=head2 content
This is the parsed JSON body of the response. Generally this will be a C<HashRef>.
=head2 raw
Returns the raw L<HTTP::
rmation from the CPAN Index.
The information is provided in a number of different formats: YAML, JSON, XML and HTML.
Information is requested by using a special URL
http://name.of.website/<prefix
he purposes of this documentation.
=over
=item C<<format>>
The format may be one of C<yaml>, C<json>, C<xml> or C<html>.
=item C<<cmd>>
The command may be one of the following:
=over
=item C<mo
refresh_token => 'secret-refresh-token',
);
my $me = $client->get('/1/user/-/profile.json');
# Dump HashRef of response
use Data::Printer;
p( $me->content );
=head1 DESCRIPT
nse> object.
my $me = $client->get('/1/user/-/profile.json');
my $activities = $client->get(
'/1/user/-/activities/list.json',
{
beforeDate => '2015-07-15T23:45:4
ponse> object.
my $delete = $client->delete(
'/1/user/-/activities/[activity-log-id].json'
);
=head2 post
Accepts a relative URL path and an optional HashRef of params. Returns a
L
package PubNub::PubSub::Message;
use Carp;
use Mojo::JSON qw(encode_json decode_json);
use strict;
use warnings;
our $VERSION = '1.0.1'; ## VERSION
=head1 NAME
PubNub::PubSub::Message - Messag
atastructure;
my $message = PubNub::PubSub::Message->new(payload=> $datastructure);
my $json = $message->json;
my $payload = $message->payload;
my $queryhash = $message->query_params;
=head1 METH
ortt, meta, ear,
and seqn, supported per the PubNub API. These other arguments are converted
to JSON in the query_params method below.
If a simple scalar is passed (not a reference), it is assumed
regexp => qr!$disp_route!,
code => \&display_editfile,
);
# Setup a route to return json data of the file
my $save_route = $plugin->save_route;
my $save_method = $plugin->save_metho
$@ ) {
$status_message = "Could not write changes to file.";
}
}
$app->send_as( JSON => { save_message => $status_message } );
}
=back
=head1 AUTHOR
Hagop "Jack" Bilemjian, C<< <
L::Tiny;
use JSON::XS;
use XML::Simple;
use HTML::Tiny;
use vars qw[$VERSION];
$VERSION = '0.40';
my %types = (
'yaml', 'application/x-yaml; charset=utf-8',
'json', 'application/json; charset=ut
return $string;
},
'json', sub {
my $ref = shift;
my $string;
eval { $string = JSON::XS->new->utf8(1)->pretty(1)->encode( $ref
ameters, an arrayref of
data to be rendered, which is required, and the format, either C<yaml>, C<json>, C<xml>
or C<html>, to render to, which defaults to C<yaml>.
=back
=head1 CLASS METHODS
=over
EVEL >= $SCRIPT_DEBUG_LEVEL then
if script_name ~= nil then
local args_str = cjson.encode( ARGV )
redis.log( redis.LOG_NOTICE, 'lua-script '..log_str..': '..script_name
LLBACK = ROLLBACK
} )
redis.log( redis.LOG_NOTICE, _FUNC_NAME..': '..cjson.encode( values ) )
end
local _setup = function ( argv_idx, func_name, extra_data_len )
LAST_
local last_cleanup_bytes_values = cjson.decode( redis.call( 'HGET', STATUS_KEY, '$_LAST_CLEANUP_BYTES' ) )
local last_cleanup_items_values = cjson.decode( redis.call( 'HGET', STATUS_KEY,
uspicious code
sub might_leak {
my $t = Test::Mojo->new('MyApp');
$t->post_ok('/search.json' => form => {q => 'Perl'})
->status_is(200);
...;
}
test_noleaks (
code
, i.e.
my $t = Test::Mojo->new('MyApp');
ok($t);
sub might_leak {
$t->post_ok('/search.json' => form => {q => 'Perl'})
->status_is(200);
...;
}
That way web-application is cr
r} . ':' . $self->{pwd}, '')};
$header->{'Content-Type'} = 'application/json' if %params;
my @extra = %params ? (json => \%params) : ();
my $tx = $ua->build_tx($method => $self->{endpoint}
->res->headers->content_type and $tx->res->headers->content_type =~ 'application/json') {
return $tx->res->json;
}
if (!$tx->success) {
$errstr = "Failed to fetch $url: " . $tx
n 0.03
=cut
our $VERSION = '0.03';
use Carp qw(cluck);
use Data::Dumper;
use REST::Client;
use JSON::XS;
use URI;
use Scalar::Util qw(blessed reftype);
use Readonly;
use Exporter 'import';
use File
de_json( $response->responseContent() ) };
if ($@) {
cluck( "Cannot parse response content "
. $response->responseContent()
. ", error msg: $@. Is this JSON?"
$query_params);
my $headers = { 'Content-Type' => 'application/json' };
my $response;
# print "JSON data ".encode_json($data);
my $f = $self->_cache_file_name($query_params, $data)
t::MD5 qw(md5_hex);
use Time::HiRes qw(usleep);
use Mojo::Redis2;
use RedisDB;
use JSON::XS qw(encode_json decode_json);
=head1 NAME
Mojo::Redis::Processor - Encapsulates the process for a Mojo app
->{prefix} . md5_hex($self->_payload);
}
sub _payload {
my $self = shift;
return JSON::XS::encode_json([$self->{data}, $self->{trigger}]);
}
sub _processed_channel {
my $self = shift;
next));
usleep($self->{usleep});
}
return if not $payload;
my $tmp = JSON::XS::decode_json($payload);
$self->{data} = $tmp->[0];
$self->{trigger} = $tmp->[1];
ret
6
# Original Author: BlueT<BlueT@BlueT.org>
# CC-BY
# Dependency - Needs
# Net/Jaiku.pm (base on JSON/Any.pm)
# LWP/UserAgent.pm
# Params/Validate.pm
#use utf8;
#~ use Data::Dumper;
use Ne
package MojoX::Session::Store::Redis;
use utf8;
use warnings;
use strict;
use Redis;
use JSON;
use base 'MojoX::Session::Store';
use namespace::clean;
__PACKAGE__->attr('redis');
__PACKAGE__->attr
te {
my ($self, $sid, $expires, $data) = @_;
my $prefix = $self->redis_prefix;
$data = encode_json($data) if $data;
$self->redis->hmset("$prefix:$sid", 'sid' => $sid, 'data' => $data, 'expires' =
y %session = $self->redis->hgetall("$prefix:$sid");
$session{'data'} = $session{'data'} ? decode_json($session{'data'}) : undef ;
return ($session{'expires'}, $session{'data'});
}
sub delete {
Locale::Wolowitz;
# ABSTRACT: Dead simple localization with JSON.
use warnings;
use strict;
use utf8;
use Carp;
use JSON::MaybeXS qw/JSON/;
our $VERSION = "1.004001";
$VERSION = eval $VERSION;
=e
ing utf-8
=head1 NAME
Locale::Wolowitz - Dead simple localization with JSON.
=head1 SYNOPSIS
# in ./i18n/locales.coll.json
{
"Welcome!": {
"he": "ברוכים הבאים!",
"es": "Bienve
select the interface's language. Also, I grew to hate the standard .po
files, and thought using a JSON format might be more comfortable.
Locale::Wolowitz allows you to provide different languages to
0.002
=head1 SYNOPSIS
# in 'foo.t', assume we want to hide Cpanel::JSON::XS
# hide Cpanel::JSON::XS -> Cpanel/JSON/XS.pm
use lib map {
my $m = $_;
sub { return unless $
_[1] eq $m; die "Can't locate $_[1] in \@INC (hidden)\n"; }
} qw{Cpanel/JSON/XS.pm};
=head1 DESCRIPTION
The L<Devel::Hide> and L<Test::Without::Module> modules are very helpful
development tools
}
# input to map is a list module names, converted to paths;
qw{Cpanel/JSON/XS.pm JSON/XS.pm}
; # end of 'use lib' statement
When perl sees a coderef in C<@INC>, it gives t
operly decoded (we recommend UTF-8 of course). For output, the default is C<application/json> encoded with L<JSON::XS>. Both the input and output types can be modified, although this is only partially
the following methods on the context object:
=over
=item C<respond>
The respond method sends a JSON response, the contents of which are encoded from the first argument:
$c->respond({ a => 1, b
ault message ("Forbidden" in this case) and the JSON body will be C<{"error":"access denied"}>.
This works too, except the value of C<error> in the JSON body of the response will just be "HTTP code 4
ns.
use strict;
use warnings;
use Carp;
use Email::Valid;
use HTTP::Tiny;
use JSON::MaybeXS qw/encode_json decode_json/;
use File::Basename;
use File::MimeInfo;
use MIME::Base64 qw/encode_base64/;
s => {
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'X-Postmark-Server-Token' => $self->{token},
},
content => encode_json($msg),
}
);
# analyze the res
ponse
if ($res->{success}) {
# woooooooooooooeeeeeeeeeeee
return decode_json($res->{content});
} else {
if ($msg->{Attachments}) {
print STDERR $res->{content};
}
croak "Failed sending