rticle/post/",
delete_url => "$SCRIPTOGRAM_API/article/delete/",
response_parser => 'JSON',
debug => 1,
);
=head1 SYNOPSIS
use WebService::Scriptogram;
my $sg = WebService:
;
use utf8;
use LWP;
use LWP::Protocol::https;
use HTML::Entities;
use URI::Escape;
use JSON::XS qw/decode_json/;
use Encode;
our $VERSION = 0.08;
sub new {
my ($class, %args) = @_;
die 'USAGE:
s->is_success;
my $json_str = (split /<!>/, $res->decoded_content)[5];
$json_str =~ s/'/"/gs;
$json_str = Encode::encode('utf-8', $json_str);
my $json = decode_json($json_str);
return 'Inva
lid response' unless defined $json->{all} && ref($json->{all}) eq 'ARRAY';
my @rslt;
for my $item(@{$json->{all}}) {
next unless ref $item eq 'ARRAY' && scalar @{$item} > 7;
my $name = de
easy Authy API
use MooX qw(
+LWP::UserAgent
+HTTP::Request::Common
+URI
+URI::QueryParam
+JSON
);
use Carp qw( croak );
our $VERSION ||= '0.000';
has api_key => (
is => 'ro',
required =
'has_useragent_timeout',
);
has json => (
is => 'ro',
lazy => 1,
builder => 1,
);
sub _build_json {
my $json = JSON->new;
$json->allow_nonref;
return $json;
}
##############################
};
}
sub make_url {
my ( $self, @args ) = @_;
my $url = join('/',$self->base_uri,'protected','json',@args);
my $uri = URI->new($url);
$uri->query_param( api_key => $self->api_key );
return $uri
s
qw(HTTP_OK HTTP_BAD_REQUEST HTTP_UNAUTHORIZED HTTP_FORBIDDEN HTTP_INTERNAL_SERVER_ERROR);
use JSON;
use LWP::UserAgent;
use Log::Log4perl qw(:easy get_logger);
use Moose qw/around has with/;
use M
ERR{'INTERNAL_SERVER'},
);
}
elsif ( $response->code > HTTP_OK ) {
my $json = JSON->new;
if ( $response->code == HTTP_BAD_REQUEST ) {
## no critic qw(Requir
NOSOpenBadRequestException->throw(
## use critic
'error' => $json->decode( $response->decoded_content ),
);
}
elsif ( $response->code =
package ZeroMQ::PubSub;
use Moose;
use ZMQ::LibZMQ2;
use JSON;
use namespace::autoclean;
with 'MooseX::Callbacks';
has 'context' => (
is => 'rw',
isa => 'ZMQ::LibZMQ2::Context',
lazy_bu
e Moose;
extends 'ZeroMQ::PubSub';
use ZMQ::LibZMQ2;
use ZMQ::Constants ':all';
use JSON qw/encode_json decode_json/;
use Carp qw/croak/;
use List::Util qw/shuffle/;
# should only be used internally
= zmq_recv($self->subscribe_sock);
my $msg_str = zmq_msg_data($msg_raw);
my $msg = decode_json($msg_str);
$self->dispatch_event($msg);
}
after 'subscribe' => sub {
my ($self, $evt, $c
re we're connected
$self->connect_publish_sock;
my $json_str = encode_json($msg);
my $res = zmq_send($self->publish_sock, $json_str);
$self->print_debug("Published $evt, res=$res");
e Moose;
extends 'ZeroMQ::PubSub';
use ZMQ::LibZMQ2;
use ZMQ::Constants ':all';
use JSON qw/encode_json decode_json/;
use Clone qw/clone/;
use Carp qw/croak/;
# socket to listen for client events
#
from JSON, or undef if failure.
=cut
sub recv {
my ($self) = @_;
my $msg = zmq_recv($self->publish_sock);
my $json_str = zmq_msg_data($msg);
my $json = eval { decode_json($json_str)
};
unless ($json) {
warn "Got invalid event: failed to parse JSON: $@";
return;
}
return $json;
}
=head2 broadcast($event)
Sends $event to all connected subscribers.
if ($args{serialize} eq "JSON") {
require JSON::Any;
JSON::Any->import;
my $json = JSON::Any->new;
$self->{serialize} = sub { $json->objToJson( [@_] ) };
$sel
f->{unserialize} = sub { (@{ $json->jsonToObj(@_) })[0] };
} elsif ($args{serialize} eq "Storable") {
require Storable;
$self->{serialize} = sub { Storable::nfreeze( [@_] )};
Any/Dump> and L<YAML::Any/Load> to serialize and deserialize
data.
=item JSON
Use L<JSON::Any/objToJson> and L<JSON::Any/jsonToObj> to serialize and
deserialize.
=item Storable
Use L<Storable/nfre
c License or the Artistic License for more details.
#
# ABSTRACT: Check the prereqs from our META.json
#---------------------------------------------------------------------
use 5.008;
our $VERSION =
ncluded a META.json:
sub prune_files
{
my $self = shift;
my $files = $self->zilla->files;
unless (grep { $_->name eq 'META.json' } @$files) {
$self->log("WARNING: META.json not found, rem
ereqs.t");
@$files = grep { $_->name ne 't/00-all_prereqs.t' } @$files;
} # end unless META.json
return;
} # end prune_files
#----------------------------------------------------------------
al DEBUG => { int => 1, default => 0, env => 1 };
use List::Util qw(min);
use Storable qw();
use JSON::XS qw();
use Sereal::Decoder qw();
use Sereal::Encoder qw();
use Compress::Zlib qw(Z_DEFAULT_COM
a => Bool,
default => 0,
);
enum DataFlexSerializerOutputFormats, [ qw(
storable
json
sereal
) ];
coerce DataFlexSerializerOutputFormats,
from Str,
via { lc $_ };
has ou
_format => (
is => 'rw',
isa => DataFlexSerializerOutputFormats,
default => 'json',
coerce => 1,
);
has sereal_encoder => (
is => 'ro',
isa => Object,
self) = @_;
my $files = $self->zilla->files;
@$files = grep { not($_->name =~ /^META\.(?:yml|json)$/ and
$_->isa('Dist::Zilla::File::OnDisk')) } @$files;
return;
} # end
[0-9.]+)/s}) {
$results{$class}{$name}{sprintf "%4d", $1} = 0+$2;
}
}
}
}
use JSON;
print JSON->new->pretty->canonical->encode(\%results);
END { chdir '/'; }
self) = @_;
my $files = $self->zilla->files;
@$files = grep { not($_->name =~ /^META\.(?:yml|json)$/ and
$_->isa('Dist::Zilla::File::OnDisk')) } @$files;
return;
} # end
s plugin).
=item C<%meta>
The hash of metadata (in META 2 format) that will be stored in F<META.json>.
=item C<$perl_prereq>
The minimum version of Perl required (from the prerequisites in the met
gs;
use JSON;
use LWP::UserAgent;
# load dotCloud environment
local $/;
open( my $fh, '<', '/home/dotcloud/environment.json' );
my $json_text = <$fh>;
my $dotcloud_env = decode_json( $json_text );
n' => $name_ver[0], 'v' => $name_ver[1]});
}
$data->{'installed'} = [ @installed ];
my $json_data = to_json($data); # , { pretty => 1 });
my $ua = new LWP::UserAgent(('agent' => "$NAME/$VERSION"))
otb.rhcloud.com/application/register/', { json_data => $json_data});
if (! $response->is_success) {
die $response->status_line;
}
my $content = from_json($response->decoded_content);
print "Difi
h my %OUTPUT => (
'json' => q{application/json},
'xml' => q{text/xml},
'php' => q{text/plain},
);
Readonly::Hash my %RESPONSE => (
'version' => {
'json' => q{{
"version":
2:{s:7:"version";s:2:"v1";s:5:"build";s:5:"0.0.1";}}}},
},
'latest_article' => {
'json' => q{{
"latest_article": [
[
{
"id": "156833"
"type": "artic
]></keyword>
</keywords>
</article>
</list>},
},
'latest_video' => {
'json' => q{{
"latest_video": [
[
{
"id": "175327"
'script[src="foo.js"]@src' => 'http://prod-server/foo.js',
'//script[2]' => 'var = ' . JSON::to_json($var_to_js),
});
__DATA__
<html>
<script type="text/javascript" src="foo.js"></scrip
head2 save_json( )
Pass in the path to a file you wish to write your javascript in. Optionally
you can pass in any options that would normally get passed to C<as_json>.
=cut
sub save_json {
my
$self, $file, @options ) = @_;
$self->_save( 'as_json', $file, @options );
}
=head2 as_json( )
as_json will return a string containing json suitable for
generating text for your RSS object. Yo
the name of the JSON object (default: RSSJSON).
=cut
sub as_json {
my ( $self, $max, $object_name ) = @_;
my $items = scalar @{ $self->{ items } };
$object_name = 'RSSJSON' unless define
package AnyMQ::Trait::Pg;
# use 5.010;
use Any::Moose 'Role';
use AnyEvent::Pg 0.04;
use JSON;
use Try::Tiny;
has 'debug' => (
is => 'rw',
isa => 'Bool',
default => 0,
);
has 'dsn' =>
);
has 'is_connected' => (
is => 'rw',
isa => 'Bool',
);
has '_json' => ( is => 'rw', lazy_build => 1, isa => 'JSON' );
has '_pg_query_watchers' => (
is => 'ro',
isa => 'ArrayRef',
construct and connect our client object
$self->_client;
}
# JSON codec pack
sub _build__json {
my ($self) = @_;
return JSON->new->utf8;
}
sub _build_client {
my ($self) = @_;
my
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,
},
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