package Business::Stripe;
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use HTTP::Request::Common qw/DELETE GET POST/;
use MIME::Base64;
our $VERSION = '0.04';
use constant URL => 'https
th, $method);
}
=head3 error (I<void>)
Method returns C<0> when encounter error conditions.
The JSON object returned by Stripe can be retrieved via this method.
print $stripe->error->{message}, "\
I<void>)
When calls are successful a positive value is returned
or if possible, the ID. Stripe's JSON object can be retrieved via
this method. Specific values are defined in the Stripe API Documentat
rowd;
our $VERSION = 0.04;
use warnings;
use Moose;
use LWP::UserAgent;
use HTTP::Request;
use JSON;
use Catalyst::Authentication::Store::Crowd::User;
has 'find_user_url' => (
is => 'ro',
t_user( $info->{username} );
if ( $response->is_success ){
my $crowd_user_info = from_json( $response->decoded_content );
return Catalyst::Authentication::Store::Crowd::User->new({
>app->{app_name},
$self->app->{password}
);
$req->header('Accept' => 'application/json');
my $response = $ua->request( $req );
return $response;
}
1;
__END__
=head1 NAME
C
age My::Memcached;
use strict;
use warnings;
use parent qw(Cache::Memcached::Fast);
use JSON;
use Hash::Compact;
my $OPTIONS = {
foo => {
alias_for => 'f',
},
w(decode_json $value, $OPTIONS);
}
sub set {
my ($self, $key, $value, $expire) = @_;
my $hash = Hash::Compact->new($value, $OPTIONS);
$self->SUPER::set($key, encode_json $hash->
erver_session_key",
load => sub {
my ($c, $key) = @_;
my $session_row;
use JSON;
unless($session_row = $c->app->schema->resultset('Session')->find($key)) {
$sessi
->id();
}
return( $key, decode_json($session_row->content));
},
store => sub {
my ($c, $key, $session_hash) = @_;
use JSON;
my $session = $c->app->schema->resu
ltset('Session')->find($key);
if($session) {
$session->content( encode_json($session_hash) );
$session->update();
}
}
});
=head1 DESCRIPTION
This is a little plugi
gile standup bot ala tender
use strict;
use warnings;
use List::Util 'shuffle';
use DateTime;
use JSON::XS;
sub load {
my ( $class, $robot ) = @_;
$robot->respond(
qr/(?:cancel|stop)
.com/api/v1/messages.json')
->header({
Authorization => "Bearer $ENV{HUBOT_STANDUP_YAMMER_TOKEN}",
Accept => 'application/json',
})
FAILED: $hdr->{Reason}");
} else {
my $data = decode_json($body);
if ($data->{messages}) {
$response->s
el free to setup your C<$driver>
this way:
package My::Workers::One;
use Moose;
use JSON::XS;
extends 'Gearman::Driver::Worker::Base';
# this method will be registered with gear
ode_json {
my ( $self, $result ) = @_;
return JSON::XS::encode_json($result);
}
sub decode_json {
my ( $self, $workload ) = @_;
return JSON::XS::decode_json($w
_method_by_name($method)->body,
decode => 'decode_json',
encode => 'encode_json',
name => $method,
},
these personalized modules on CPAN. I even bantered
around the idea of using L<MetaCPAN's author JSON input|https://github.com/SineSwiper/Dist-Zilla-PluginBundle-BeLike-You/blob/master/BeLike-You.pod
nfig_short_merge('Test::EOL', { trailing_whitespace => 0 }),
#
# [Test::CPAN::Meta::JSON]
# [Test::CheckDeps]
# [Test::Portability]
# ;[Test::Pod::LinkCheck] ; Both of
]
# [Test::UseAllModules]
# [Test::Version]
(map { 'Test::'.$_ } qw(CPAN::Meta::JSON CheckDeps Portability Synopsis MinimumVersion CheckManifest DistManifest UseAllModules Version)),
# ; META maintenance
# [MetaConfig]
# [MetaJSON]
# [MetaYAML]
qw( CheckPrereqsIndexed MetaConfig MetaJSON MetaYAML ),
#
# [MetaNoIndex]
# dire
method will be returned to the Gearman
client. This is useful to serialize Perl datastructures to JSON
before sending them back to the client.
sub do_some_job : Job : Encode : Decode {
my
ad ) = @_;
return { message => 'OK', status => 1 };
# calls 'encode' and returns JSON string: {"status":1,"message":"OK"}
}
sub custom_encoder : Job : Encode(enc_yaml) : Deco
lf, $result ) = @_;
return JSON::XS::encode_json($result);
}
sub decode {
my ( $self, $workload ) = @_;
return JSON::XS::decode_json($workload);
}
sub enc_yam
path, $settings, $remove_expiration) = @_;
# this assumes the api converts 1 and 0 to JSON::true and JSON::false accordingly
if ($remove_expiration) {
$remove_expiration = 1;
} else {
$remo
package Net::Dropbox::API;
use common::sense;
use File::Basename qw(basename);
use JSON;
use Mouse;
use Net::OAuth;
use LWP::UserAgent;
use URI;
use HTTP::Request::Common;
use Data::Random qw(rand_ch
lls the users info from dropbox.
=cut
sub account_info {
my $self = shift;
return from_json($self->_talk('account/info'));
}
=head2 list
lists all files in the path defined:
$data =
_json({ http_response_code => 304 });
} else {
return $self->_talk_default_error_handler($resp);
}
},
};
}
return from_json(
.
=over
=cut
=item DateTime::Duration::TO_JSON
This is defined here to serialize durations as postgres intervals.
=cut
sub DateTime::Duration::TO_JSON {
my $d = shift;
return DateTime::F
urn $res unless ref $names && ref $types;
# Force all bigints into numeric context for JSON. (see JSON::XS)
my %name2type = mesh @$names, @$types;
return $res unless grep /int8/, @$types
ERS{$_[1]} }
eval {
require JSON;
JSON->import(2.00);
register_read_type(json => \&JSON::decode_json);
register_write_type(json => \&JSON::encode_json);
};
1;
__END__
=head1 NAME
Z
;
$sock->send($msg);
}
# json (if JSON.pm is available)
$sock->send_as( json => { foo => "bar" } );
my $thing = $sock->recv_as( "json" );
# custom serialization
ZeroM
ample, for JSON we do
the following (this is already done for you in ZeroMQ.pm if you have
JSON.pm installed):
use JSON ();
ZeroMQ::register_write_type('json' => \&JSON::encode_json);
Zer
use AnyEvent::HTTP::ScopedClient;
use AnyEvent::Campfire::Stream;
use URI;
use MIME::Base64;
use JSON::XS;
use Try::Tiny;
extends 'AnyEvent::Campfire';
has 'account' => (
is => 'ro',
isa =
my ( $self, $room, $text ) = @_;
$self->post(
"/room/$room/speak",
encode_json( { message => { body => $text } } ),
sub {
my ( $body, $hdr ) = @_;
);
}
sub put_room {
my ( $self, $room, $room_info, $callback ) = @_;
$room_info = encode_json($room_info) if ref($room_info) eq 'HASH';
$self->put( "/room/$room", $room_info, $callback );
',
);
has extra_data => (
is => 'ro',
predicate => 'has_extra_data',
);
sub TO_JSON {
my $self = shift;
return {
($self->has_errors ? (errors => $self->erro
address => 'Maybe[Location]',
};
use JSON;
# note the lack of Location,
# which is fine because it
# was Maybe[Location]
my $data = decode_json(q[
{
"id": "1234-A",
the data to the
doctype.
=head2 TO_JSON
Returns a hashref with keys of C<errors> and C<extra_data>, containing the
values of those attributes. This allows L<JSON> to properly encode the error
objec
,
isa => AbsDir,
coerce => 1,
default => sub { dir(".")->absolute }
);
# where environment JSON files and node subdirectories are stored
sub _environment_dir {
my ($self) = @_;
my $path = $
$path;
}
# file path where environment JSON file is located
sub _environment_path {
my ($self, $env) = @_;
return $self->_environment_dir->file("${env}.json");
}
sub _node_path {
my ($self, $n
rn $self->_node_dir($env)->file("${node_name}.json");
}
sub _role_path {
my ($self, $role_name) = @_;
return $self->_role_dir->file("${role_name}.json");
}
sub _cookbook_path {
my ($self, $coo
new;
}
$data->{json_class} = "Chef::Environment";
$data->{chef_type} = "environment";
return $data;
}
sub _thaw {
my ($self, $data) = @_;
delete $data->{$_} for qw/json_class chef_type/;
ll be prompted to confirm
deletion.
=head3 show
$ pantry show node NAME
Prints to STDOUT the JSON data for the given C<NAME>.
=head3 apply
$ pantry apply node NAME --recipe nginx --role mail
al string containing 'true' or 'false', it will be
replaced in the configuration data with actual JSON boolean values.
N.B. While the term C<--default> is used for command line consistency, attribute
iable C<EDITOR> on
the configuration file for the C<name> node.
The resulting file must be valid JSON in a form acceptable to Chef. Generally,
you should use the C<apply> or C<strip> commands instea
og::Dispatch;
use Log::Dispatch::Message::Passing;
use Message::Passing::Filter::Encoder::JSON;
use Message::Passing::Output::ZeroMQ;
my $log = Log::Dispatch->new;
$log->add(Log:
egate_log',
min_level => 'debug',
output => Message::Passing::Filter::Encoder::JSON->new(
output_to => Message::Passing::Output::ZeroMQ->new(
connect =>
run_list ];
}
$data->{json_class} = "Chef::Role";
$data->{chef_type} = "role";
return $data;
}
sub _thaw {
my ($self, $data) = @_;
delete $data->{$_} for qw/json_class chef_type/;
for m