package NetDNA;
use strict;
use warnings;
use JSON;
use Net::OAuth;
use LWP::UserAgent;
use URI;
use Data::Dumper;
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
my $base_url = "ht
# Decode JSON
my $decoded_json = decode_json($res->content);
if($decoded_json->{code} == 200) {
if($debug){
print Dumper $decoded_json->{data};
}
ed_json->{data};
} else {
if($debug){
print Dumper $decoded_json->{error};
}
return $decoded_json->{error};
}
}
#################### main pod docum
ead2 filename
An attribute for the file name to write to.
=head2 consume
Consumes a message by JSON encoding it and printing it, followed by \n
=head1 SEE ALSO
L<Message::Passing>
=head1 SPONSOR
package Thrift::JSONProtocol;
=head1 NAME
Thrift::JSONProtocol
=head1 DESCRIPTION
JSON protocol implementation for thrift.
This is a full-featured protocol supporting write and read.
This code w
H => '\\',
ZERO => '0',
ESCSEQ => join('','\\','u','0','0'),
VERSION => 1,
JSON_CHAR_TABLE => [
# 0 1 2 3 4 5 6 7 8 9 A B C D E F
0,
lf->{context_} = Thrift::JSONProtocol::JSONBaseContext->new( protocol => $self );
# Reader that manages a 1-byte buffer
$self->{reader_} = Thrift::JSONProtocol::LookaheadReader->ne
ABSTRACT: PunchTab REST API
use strict;
use warnings;
use LWP::UserAgent;
use MIME::Base64;
use JSON;
use Digest::SHA;
use Carp;
use vars qw/$errstr/;
sub errstr { $errstr }
sub new {
my $class
f = shift;
my %user = @_ % 2 ? %{ $_[0] } : @_;
my $auth_request = encode_base64( encode_json( \%user ) );
my $timestamp = time();
my $signature = Digest::SHA::hmac_sha1_hex( "$
>is_success ) {
$errstr = $resp->status_line;
return;
}
my $data = decode_json( $resp->decoded_content );
if ( $data->{error} ) {
$errstr = $data->{error}->{descrip
efault => 'Null' ),
CLIComponent( name => 'decoder', default => 'JSON' ),
CLIComponent( name => 'encoder', default => 'JSON' ),
CLIComponent( name => 'error', default => 'STDERR' ),
CL
IComponent( name => 'error_encoder', default => 'Message::Passing::Filter::Encoder::JSON' ),
'Message::Passing::Role::Script';
option configfile => (
is => 'ro',
format => 's',
);
sub ge
=head2 BASIC PREMISE
You have data for discrete events, represented by a hash (and
serialized as JSON).
This could be a text log line, an audit record of an API
event, a metric emitted from your app
RSION = '0.13';
}
use Mason::PluginRole;
use Poet qw($conf $poet);
use Poet::Plack::Response;
use JSON::XS;
use Try::Tiny;
has 'req' => ( is => 'ro', required => 1, isa => 'Object' );
has 'res' => (
elf->req->session;
}
method send_json ($data) {
$self->clear_buffer;
$self->print( JSON::XS::encode_json($data) );
$self->res->content_type("application/json");
$self->abort();
}
1;
_json ($data)
Output the JSON-encoded I<$data>, set the content type to "application/json",
and abort. e.g.
method handle {
my $data;
# compute data somehow
$m->send_json
($data);
}
C<send_json> is a shortcut for
$m->clear_buffer;
$m->print(JSON::XS::encode_json($data));
$m->res->content_type("application/json");
$m->abort();
=back
=head1 SEE AL
t
use strict;
use warnings;
use base qw(Thrift::Parser::Type);
use Scalar::Util qw(blessed);
use JSON::XS;
=head1 USAGE
Stringification is overloaded to the values 'true' or 'false'.
When composin
ss, $value) = @_;
if (ref $value && blessed($value) && $value->isa('JSON::XS::Boolean')) {
$value = $value == JSON::XS::true ? 1 : 0;
}
return $class->SUPER::compose($value);
}
er within a chain.
message_chain {
encoder fooenc => ( output_to => 'out', class => 'JSON' );
....
};
Class names will be assumed to prefixed with 'Message::Passing::Filter::
in a chain.
message_chain {
decoder zmq_decode => ( output_to => 'filter', class => 'JSON' );
....
};
Class names will be assumed to prefixed with 'Message::Passing::Filter::
s around before after with) ];
use MooX::Options;
use MooX::Types::MooseLike::Base qw/ Str /;
use JSON ();
use Try::Tiny qw/ try /;
sub make_variant {
my ($class, $target_package, %arguments) = @
my $str = shift;
if (! ref $str) {
try {
$str = JSON->new->relaxed->decode($str)
};
}
$str;
},
tional attribute called C<< "${name}_options" >> will also be added,
which coerces a hashref from JSON.
=head2 default
A default value for the main attribute. If this is not supplied, than the attri
NetDNA( 'jdorfman', 'fbe242bcaf4c95ed39a', 'e1429ab0873d0f');
$api->get("/account.json");
$api->get("/account.json", 1);
# Get first name which is set using constructor.
#$alias = $api->getAlias()
t;
use warnings;
package Pantry::Role::Serializable;
# ABSTRACT: A role to save/load data to/from JSON files
our $VERSION = '0.012'; # VERSION
use MooseX::Role::Parameterized;
use Moose::Util qw/get_
use File::Path qw/mkpath/;
use File::Slurp qw/read_file write_file/;
use Storable qw/dclone/;
use JSON 2;
parameter freezer => (
isa => 'Str',
);
parameter thawer => (
isa => 'Str',
);
role {
w", scalar_ref => 1 } );
# XXX check if string needs UTF-8 decoding?
my $data = $class->_json_thaw( $str_ref );
if ($thawer) {
$data = $class->$thawer($data);
}
$data->{_p
g::Output::STDERR';
require_module 'Message::Passing::Filter::Encoder::JSON';
Message::Passing::Filter::Encoder::JSON->new(
output_to => Message::Passing::Output::STDERR->new,
);
}
he error chain.
By default, this is a chain of:
=over
=item Message::Passing::Filter::Encoder::JSON
=item Message::Passing::Output::STDOUT
=back
=head1 WARNINGS
=head2 ERROR CHAINS CAN LOOP
If
eue
use strict;
use warnings;
use v5.10;
use Test::More 0.96;
use PICA::Modification;
use Test::JSON::Entails;
use parent 'Exporter';
our @EXPORT = qw(test_queue);
sub test_queue {
my $queue = sh
ormsMultipart',
'application/xml' => 'HTTP::Body::XForms',
'application/json' => 'HTTP::Body::OctetStream',
};
require HTTP::Body::OctetStream;
require HTTP
ON
HTTP::Body parses chunks of HTTP POST data and supports
application/octet-stream, application/json, application/x-www-form-urlencoded,
and multipart/form-data.
Chunked bodies are supported by not
FIXME
GraphViz
GUID
GUIDs
HTTP
HTTPS
IETF
IP
IPv4
IPv6
IRC
ISP
ISP's
JSON
MakeMaker
Markdown
Middleware
MongoDB
mkdn
modulino
MVC
OO
OOP
PARC
PHP
P
ed by the spell check.
The stopword list includes some CPAN author names, technical terms (e.g. JSON,
URI) and other commonly-used words not included in the default word list (e.g.
mixin, munging).
asename qw/dirname basename/;
use File::Slurp qw/read_file/;
use IPC::Cmd qw/can_run/;
use JSON qw/decode_json/;
use namespace::clean;
sub abstract {
return 'Edit items in a pantry (nodes, roles,
failed!: $!";
eval { decode_json(read_file($path,{ binmode => ":raw" })) };
if ( my $err = $@ ) {
$err =~ s/, at .* line .*//;
warn "Warning: JSON errors in config for $name\n";
ESCRIPTION
This class implements the C<pantry edit> command, which is used to open the node data
JSON file in an editor for direct editing.
=for Pod::Coverage options validate
=head1 AUTHOR
David
package Message::Passing::Role::Output;
use Moo::Role;
use JSON qw/ to_json /;
use Scalar::Util qw/ blessed /;
#use namespace::clean -except => 'meta';
requires 'consume';
no Moo::Role;
1;
=head1
Dancer ':syntax';
use Dancer::Plugin;
use Carp;
use Try::Tiny;
use Capture::Tiny qw(capture);
use JSON::XS qw();
use Scalar::Util qw(blessed);
# POE sessions will be created by Tapir::MethodCall; let
alidator;
use Tapir::MethodCall;
use Tapir::Documentation::NaturalDocs;
use File::Spec;
my $json_xs = JSON::XS->new->allow_nonref->allow_blessed;
our $VERSION = 0.04;
register setup_tapir_documenta
t->params;
# Decode the JSON payload
if ($request->content_length && $request->content_type && $request->content_type eq 'application/json' && length $request->body) {
package Message::Passing::Types;
use MooseX::Types ();
use Moose::Util::TypeConstraints;
use JSON ();
use MooseX::Types::Moose qw/ Str HashRef ArrayRef /;
use MooseX::Types::Common::String qw/ NonEmpt
-declare => [qw{
Output_Type
Input_Type
Filter_Type
Codec_Type
Hash_from_JSON
JSON_from_Hash
ArrayOfStr
}];
role_type Input_Type, { role => 'Message::Passing::Role::Input
m_JSON,
as HashRef;
coerce Hash_from_JSON,
from NonEmptySimpleStr,
via { try { JSON->new->relaxed->decode($_) } };
MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
Hash_from_JSON,