$self->util->methods... or not
has _json => (
is => 'rw'
, isa => 'JSON::XS'
, lazy => 1
, required => 1
, default => sub {
require JSON::XS;
return JSON::XS->new->utf8->ascii->relaxed;
}
ent', tied => 1 );
}
# Leave it up to the API implementation to encode the hash/array ref into JSON / Form data / XML / etc.
$req->content( $args{content} ) if defined $args{content};
$req->metho
ncode {
my ( $self, %args ) = @_;
my ( $data );
for ( $args{type} ) {
when ( 'json' ) {
$data = $self->_json->encode( $args{data} );
}
when ( 'xml' ) {
$data = $self->_xml->write( $arg
package App::gh::API;
use warnings;
use strict;
use Carp ();
use LWP::UserAgent;
use URI;
use JSON;
use App::gh::Utils;
use Try::Tiny;
use Net::GitHub;
sub new_ua {
my $class = shift;
my $ua
do{\(my $o = 1)}, 'JSON::Boolean' ),
'has_issues' => $VAR1->{'repository'}{'has_downloads'},
'name' => 'App-gh',
'private' => bless( do{\(my $o = 0)}, 'JSON::Boolean' ),
e Curses qw/KEY_ENTER/;
use TiddlyWeb::Wikrad qw/$App/; # XXX cyclic
use TiddlyWeb::EditPage;
use JSON;
use Data::Dumper;
use YAML ();
sub new {
my $class = shift;
my $self = $class->SUPER::
ta ...');
$r->accept('application/json');
my $page_name = $App->get_page;
my $json_text = $r->get_page($page_name);
my $page_data = from_json($json_text);
$App->{cui}->nostatus;
ha1);
use MIME::Base64;
use LWP::UserAgent;
use Encode;
use XML::Twig;
use URI::Encode;
use JSON;
use Carp;
use Data::Dumper;
subtype 'CloudStack::YN'
=> as 'Str'
=> where { $_ =~
st' => (
is => 'rw',
isa => 'CloudStack::YN',
default => 'no',
);
has 'xml_json' => (
is => 'rw',
isa => 'Str',
default => 'xml',
);
has 'url' => (
i
f->secret_key."\n";
print "SEND_REQUEST:".$self->send_request."\n";
print "XML_JSON:".$self->xml_json."\n";
}
### SUB ROUTINE ###
### COMMAND ###
sub proc{
my ($self, $cmd, $o
SYNOPSIS
package MyContainer;
use parent 'Micro::Container';
__PACKAGE__->register(
JSON => [],
);
package MyContainer::Child;
use parent 'MyContainer';
__PACKAGE__->register(
yContainer::Child;
my $container = MyContainer::Child->instance;
say $container->get('JSON')->encode_json({ foo => 'bar' });
my $data = $container->get('MessagePack')->decode($message_pack_stri
ter(
'LWP::UserAgent' => [ agent => 'FooBar' ],
JSON => sub {
my $c = shift;
$c->load_class('JSON')->new->utf8;
},
);
=head2 unregister(@names)
=h
package TiddlyWeb::EditPage;
use warnings;
use strict;
use Carp qw/croak/;
use File::Temp;
use JSON::XS;
use Encode;
=head1 NAME
TiddlyWeb::EditPage - Edit a wiki page using your favourite EDITOR.
is mandatory";
my $rester = $self->{rester};
$rester->accept('application/json');
my $pages = decode_json($rester->get_taggedpages($tag));
unless (@$pages) {
die "No pages fou
ead1 SYNOPSIS
use DBI;
use JSON::Any;
use LWP::Simple;
# Example JSON object
my $json = get 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Pennsylvania+Ave+NW,+2
0500®ion=us&language=en&sensor=false';
my $obj = JSON::Any->jsonToObj($json);
my $dbh = DBI->connect('dbi:TreeData:', '', '', {
tree_table_name => 'geocode',
tree_data
ng. (Any caveats with those modules likely applies here.)
This module can be handy to translate JSON, XML, YAML, and many other tree formats to be used in class sets like L<DBIx::Class>. Unlike
L<D
ead1 SYNOPSIS
use DBI;
use JSON::Any;
use LWP::Simple;
# Example JSON object
my $json = get 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Pennsylvania+Ave+NW,+2
0500®ion=us&language=en&sensor=false';
my $obj = JSON::Any->jsonToObj($json);
my $dbh = DBI->connect('dbi:TreeData:', '', '', {
tree_table_name => 'geocode',
tree_data
ng. (Any caveats with those modules likely applies here.)
This module can be handy to translate JSON, XML, YAML, and many other tree formats to be used in class sets like L<DBIx::Class>. Unlike
L<D
s::Accessor/;
use Data::Recursive::Encode;
use DateTime::Format::ISO8601;
use Hash::AsObject;
use JSON;
use LWP::UserAgent;
use URI;
# Accessors
__PACKAGE__->mk_accessors( qw/ iter / );
# Constructo
ess($response->is_success){
die 'Fetch error: '.$response->status_line;
}
# Decode JSON
my $js_hash = JSON->new->utf8->decode($response->content);
# Encoding
if(defined($self->{encoding})){
t;
my ($json_url) = @_;
my $EXIT_CODE = 1;
my $browser = WWW::Mechanize->new(
stack_depth => 0,
timeout => 3,
autocheck => 0,
);
$browser->get( $json_url );
warnings;
use URI::Escape;
use LWP::UserAgent;
use HTTP::Request;
use Class::Field 'field';
use JSON::XS;
use Readonly;
our $VERSION = '0.1';
Readonly my $BASE_URI => '';
Readonly my %ROUTES =>
er';
field 'query';
field 'etag_cache' => {};
field 'http_header_debug';
field 'response';
field 'json_verbose';
field 'cookie';
field 'agent_string';
sub new {
my $invocant = shift;
my $clas
name => $pname, ws => $workspace }
);
$uri .= '?verbose=1' if $self->json_verbose;
$accept = 'application/json' if $accept eq 'perl_hash';
my ( $status, $content, $response ) = $self-
e AnyEvent;
use AnyEvent::HTTP;
use AnyEvent::SKKServ;
use Cache::Memory::Simple;
use Encode;
use JSON;
use URI;
use constant {
SERVER_ERROR => '0',
SERVER_FOUND => '1',
SERVER_NO
che::Memory::Simple->new();
my $expire = 60 * 60 * 24;
my $enc = find_encoding('euc-jp');
my $json = JSON->new->utf8(1)->relaxed(1);
my $_uri = URI->new('http://www.google.com/transliterate');
sub _
timeout => 1, sub {
if ($_[1]->{Status} == 200) {
my $res = $json->decode($_[0]);
my @words;
for my $word (@{$res->[0][1]})
s::Accessor/;
use Data::Recursive::Encode;
use DateTime::Format::ISO8601;
use Hash::AsObject;
use JSON;
use LWP::UserAgent;
use URI;
# Accessors
__PACKAGE__->mk_accessors( qw/ iter / );
# Constructo
ess($response->is_success){
die 'Fetch error: '.$response->status_line;
}
# Decode JSON
my $js_hash = JSON->new->utf8->decode($response->content);
# Encoding
if(defined($self->{encoding})){
f>
Format used to output different text data, like rows, columns description etc.
Can be "xml", "json", "yaml", "html", "htmltable" or "native" for now, defaults
to "native".
Note a special case of
anipulation methods
=over
=item load
Parses input data in configured string format (e.g. YAML, JSON or XML) and
returns perl structure (hashref or arrayref).
Input: $string_data.
Output: $parsed_d
s) > 0;
};
}
=item dump
Convert perl structure into string of configured format (e.g. YAML, JSON or
XML).
Input: $data.
Output: $string.
Uses configured dumper to serialize perl structure into
ey ( @keys ) {
my $ref = $self->service_stats($key);
print $self->json->encode([$key,$ref]), "\n";
}
}
);
}
1;
__END__
=encoding utf8
=head
ervices _proclet/]
);
use JSON qw//;
my $_JSON = JSON->new()
->utf8(1)
->shrink(1)
->space_before(0)
->space_after(0)
->indent(0);
sub json {
$_JSON;
}
sub exists_service {
open my $fh, '<', $service->{file} or return;
my $val = do { local $/; <$fh> };
$self->json->decode($val);
}
sub service_keys {
my $self = shift;
keys %{$self->_services};
}
my %w
class to make App::derived Plugin.
=head1 METHODS
=over 4
=item new
=item json(): Object
Utility method. returns JSON.pm object
=item service_stats($key): HashRef
Retrieve service status
=item
&YAML::Tiny::Dump,
\&YAML::Tiny::Load,
],
json => [
'JSON/Syck.pm',
\&JSON::Syck::Dump,
\&JSON::Syck::Load,
],
);
=item init
Initialize dumper and
y);
if ( $mode eq 'full' ) {
my $val = $self->json->encode($ref);
$result .= join $DELIMITER, "VALUE", $key, 0, length($
cached->get('slowqueris:latest'); # only latest value.
say $memcached->get('slowqueris:full'); #JSON formated data include raw values
=head1 SEE ALSO
<drived>, <App::derived::Plugin> for writing
05;
use File::Temp qw/tempfile/;
use File::Copy;
use Proclet;
use JSON ();
use Log::Minimal;
our $VERSION = '0.10';
my $_JSON = JSON->new()
->utf8(1)
->shrink(1)
->space_before(0)
->
($key, $cmd) = @_;
my ($tmpfh,$tmpfile) = tempfile(UNLINK=>0, EXLOCK=>0);
print $tmpfh $_JSON->encode({
status=>"INIT",
persec => '0E0',
latest => '0E0',
});
c
my ($writefile, $body) = @_;
my ($tmpfh,$tmpfile) = tempfile(UNLINK=>0);
print $tmpfh $_JSON->encode($body);
close($tmpfh);
move( $tmpfile, $writefile);
}
1;
__END__
=encoding utf