a non-issue.
=head2 Storage Formats
The storage format is supposed to be platform-independent. JSON seems like a
good default encoding, however it requires strings to be in Unicode. When you
encod
ll which were which. This means that
if you take a unicode-as-octets filename and encode it with JSON and decode it
again, perl will mangle it when you attempt to open the file, and fail. It
also me
names
which are not valid UTF-8 are encoded as structures which can be restored
when decoding the JSON.
=head2 Conclusion
In the end, I came up with a module called L<DataStore::CAS::FS::InvalidUTF8
:CAS::FS::DirCodec::Minimal;
use 5.008001;
use strict;
use warnings;
use Try::Tiny;
use Carp;
use JSON 2.53 ();
require DataStore::CAS::FS::InvalidUTF8;
require DataStore::CAS::FS::Dir;
*decode_utf8=
$entry_list;
my $ret= "CAS_Dir 00 \n";
if ($metadata and scalar keys %$metadata) {
my $enc= JSON->new->utf8->canonical->convert_blessed;
$ret .= $enc->encode($metadata);
}
$ret .= "\0";
$re
ing end of metadata";
if ($meta_end > 0) {
my $enc= JSON->new()->utf8->canonical->convert_blessed;
DataStore::CAS::FS::InvalidUTF8->add_json_filter($enc);
$params->{metadata}= $enc->decode(subs
= '0.07';
our $EXTENTIONS_MAP = {
pl => 'Perl',
perl => 'Perl',
js => 'JSON',
json => 'JSON',
yml => 'YAML',
yaml => 'YAML',
};
sub new {
my $class = shift;
bles
C<< Perl >>, C<< JSON >> and C<< YAML >> format.
The file format is determined by the extension type. extensions map are:
pl => Perl
perl => Perl
js => JSON
json => JSON
yml => YAML
n considers that file is envfile.
Also, if you use C<< YAML >> and C<< JSON >>, L<< Data::Encoder >> and L<< YAML >> or L<< JSON >> module is required.
=head1 AUTHOR
xaicron E<lt>xaicron@cpan.orgE<
st;
use Plack::Util::Accessor qw(route method path receipt_data allow_sandbox shared_secret);
use JSON;
use Try::Tiny;
use Furl;
sub prepare_app {
my $self = shift;
$self->allow_sandbox( $se
$params{password} = $self->shared_secret if $self->shared_secret;
my $receipt_data = encode_json (\%params);
my $res;
$res = $self->_post_receipt_to_itunes( 'production', $receipt_data,
> 'application/json'], # headers
$receipt_data, # form data (HashRef/FileHandle are also okay)
);
return [200, ['Content-Type' => 'application/json'], [$res->cont
' ' . $WebService::Rackspace::DNS::VERSION);
$self->content_type('application/json');
# $self->extension('json');
$self->auth_type('none');
$self->mapping({
user => 'us
Store::CAS::FS::DirCodec::Unix;
use 5.008;
use strict;
use warnings;
use Try::Tiny;
use Carp;
use JSON 2.53 ();
use Scalar::Util 'looks_like_number';
require DataStore::CAS::FS::Dir;
require DataStore
y encode only the attributes of a UNIX stat()
our $_json_coder;
sub _build_json_coder {
DataStore::CAS::FS::InvalidUTF8->add_json_filter(
JSON->new->utf8->canonical->convert_blessed, 1
);
}
our
{_}{gmap}= \%gmap;
my $meta_json= ($_json_coder ||= _build_json_coder())->encode($metadata);
my $ret= "CAS_Dir 04 unix\n"
.pack('N', length($meta_json)).$meta_json
.join('', sort { substr($a,4
:Perl::Distmap::VERSION = '0.2.0';
}
# ABSTRACT: A reader/writer for the C<metadata/perl/distmap.json> file.
use 5.010000;
use Moose;
has map => (
isa => 'Gentoo::Perl::Distmap::Map',
is
2] }
sub decoder {
return state $json = do { require JSON; JSON->new->pretty->utf8->canonical; }
}
sub encoder {
return state $json = do { require JSON; JSON->new->pretty->utf8->canonical; }
}
for the C<metadata/perl/distmap.json> file.
=head1 VERSION
version 0.2.0
=head1 SYNOPSIS
my $dm = Gentoo::Perl::Distmap->load( file => '../path/to/distmap.json' );
$dm->save( file => '/tmp/fo
"D Min7 4" );
# Add section to song.
$song->add_section($section);
# Export as json.
print $song->json, "\n";
=head1 DESCRIPTION
Chordbot is a songwriting tool / electronic backup band fo
ordBot can import and export songs in JSON format. Music::ChordBot
provides a set of modules that can be used to programmatically
build songs and produce the JSON data suitable for import into
ChordBo
package Finance::MtGox;
use warnings;
use strict;
use Carp qw( croak );
use JSON::Any;
use WWW::Mechanize;
use URI;
use Time::HiRes qw( gettimeofday );
use Digest::SHA qw( hmac_sha512 );
use MIME::Ba
rgs->{secret}
or croak "You must provide 'key' and 'secret' credentials.";
$args->{json} = JSON::Any->new;
$args->{mech} = WWW::Mechanize->new(stack_depth => 0);
return bless $args
2 call( $name )
Run the API call named C<$name>. Returns a Perl data structure
representing the JSON returned from MtGox.
=cut
sub call {
my ( $self, $name ) = @_;
croak "You must provide
construct a CordBot song. Upon program termination, the song is
written out to standard output in JSON format, suitable for import into
the ChordBot app.
=cut
our $VERSION = 0.01;
use Music::ChordB
he program.
sub END {
_export() if $song;
}
sub json { $song->json }
sub _export {
binmode( STDOUT, ':utf8');
print STDOUT $song->json, "\n";
}
=head1 QUICK ACCESS CHORDS
For convenien
ccess to unofficial API of booklog.jp
our $VERSION = 'v0.0.1'; # VERSION
use LWP::UserAgent;
use JSON::Any;
sub new
{
my ($self) = @_;
my $class = ref $self || $self;
return bless {
_UA => LWP:
_} } keys %$data;
$param = "?$param" if length $param;
my $ret = JSON::Any->from_json($self->{_UA}->get('http://api.booklog.jp/json/'.$account.$param)->content);
$ret->{category} = {} if ref $ret->
rn $ret;
}
sub get_review
{
my ($self, $book_id) = @_;
my $ret = JSON::Any->from_json($self->{_UA}->get('http://booklog.jp/json/review/'.$book_id)->content);
return $ret->{$book_id} if exists $re
package App::BCSSH::Handler;
use Moo::Role;
use JSON qw(encode_json decode_json);
use App::BCSSH::Message;
use MooX::CaptainHook qw(on_application);
my %handlers;
sub handlers {
return %handlers;
{
my ($self, $args, $send, $socket) = @_;
my $json_send = sub {
my @response = @_;
my $rmessage = @response ? encode_json(\@response) : '';
$send->(BCSSH_SUCCESS, $rme
ssage);
return $socket;
};
my $handler_args = decode_json($args);
$self->handle($json_send, @$handler_args);
return;
}
sub handler {
my $self = shift;
return sub {
package Net::Groonga::HTTP::Response;
use strict;
use warnings;
use utf8;
use JSON::XS qw(decode_json);
use Data::Page;
use Net::Groonga::Pager;
use Mouse;
has function => (
is => 'rw',
requ
e->code ne 200;
return $self->http_response->content if $self->function eq 'dump';
decode_json($self->http_response->content);
}
sub return_code {
my $self = shift;
Carp::croak(sprint
ethods return method dies if the response is not I<200 OK>.
=over 4
=item $res->data() :Object
JSON decoded content body.
=item $res->return_code() :Int
Shorthand for C<< $res->data->[0]->[0] >>.
'Memcached' => { servers => ['127.0.0.1'] }
],
serialization => 'JSON',
expires => 3600,
fields => {
user => {
inflate => s
App::BCSSH::Message qw(send_message BCSSH_SUCCESS BCSSH_FAILURE BCSSH_COMMAND);
use JSON qw(encode_json decode_json);
use Moo::Role;
has 'agent' => ( is => 'ro', default => sub { $ENV{SSH_AUTH_SOCK}
@_;
my $key = $self->auth_key || '';
my $message = join '|', $self->handler, $key, encode_json(\@args);
my ($rtype, $rmessage) = send_message($self->agent_socket, BCSSH_COMMAND, $message);
unless (defined $rmessage && length $rmessage) {
return;
}
my $response = decode_json($rmessage);
return wantarray ? @$response : 1;
}
1;
__END__
=head1 NAME
App::BCSSH::Client
al_machines');
$self->auth_type('basic');
$self->content_type('application/json');
$self->extension('json');
$self->wrapper('virtual_machine');
$self->mapping({
os
Plack::Component);
use Plack::Util::Accessor qw( dsn dbh);
use Plack::Request;
use JSON::PP qw(encode_json decode_json);
use parent qw(Exporter);
our $VERSION = '0.06';
our @EXPORT = qw(pgrest);
sub
1 ? @_ : dsn => 'dbi:Pg:'.$_[0] )->to_app;
}
# maintain json object field order
use Tie::IxHash;
my $obj_parser_sub = \&JSON::PP::object;
*JSON::PP::object = sub {
tie my %obj, 'Tie::IxHash';
$obj_
$n = shift;
return $n unless $n;
return decode_json $n
}
method select($param, $args) {
use Data::Dumper;
my $req = encode_json({
collection => $args->{collection},
l
int format_pretty($data);
# explicitly select a formatter
print format_pretty($data, {module=>'JSON'});
# specify formatter option(s)
print format_pretty($data, {module=>'Console', interactive=>
use.
To develop a formatter, look at one of the formatter modules (like
L<Data::Format::Pretty::JSON>) for example. You only need to specify one
function, C<format_pretty>.
=head1 FUNCTIONS
=head2
er, like L<Data::Format::Pretty::Console>,
L<Data::Format::Pretty::HTML>, L<Data::Format::Pretty::JSON>,
L<Data::Format::Pretty::YAML>.
Alternative data formatting framework/module family: L<Any::Ren
Net::Groonga::HTTP;
use 5.008005;
use strict;
use warnings;
our $VERSION = "0.03";
use JSON::XS qw(encode_json);
use Furl;
use URI;
use Net::Groonga::HTTP::Response;
use Mouse;
has end_point => (
ll($function, %args);
};
}
sub load {
my ($self, %args) = @_;
$args{values} = encode_json($args{values}) if ref $args{values};
return $self->call('load', %args);
}
1;
__END__
=encod
,
values => \@values,
);
Load the data to database. This method encodes I<values> to JSON automatically, if it's arrayref.
=item $groonga->select(%args)
=item $groonga->status(%args)
=
em Filtering, etc
Of objects, requests, etc. Javascript or serverside, it doesn't matter.
=item JSON/YAML/XML feeds
Maybe it's useful for someone.
=back
=head1 MINI-TUTORIAL
=head2 Why use LeakT