=> 'application/javascript',
js => 'text/html',
json => 'application/json',
rss => 'application/xml',
txt => 'text/plain',
db;
use strict;
use warnings;
use base 'MojoX::Session::Store';
use Mojo::UserAgent;
use Mojo::JSON;
__PACKAGE__->attr(is_async => 1);
__PACKAGE__->attr(client => sub { Mojo::UserAgent->new; } );
eturn $url;
}
sub _encode_json {
my $self = shift;
my $data = shift;
my $json = Mojo::JSON->new;
$data = $json->encode($data);
unless ($data && !$json->error) {
$self->e
turn $data;
}
sub _decode_json {
my $self = shift;
my $body = shift;
my $json = Mojo::JSON->new;
$body = $json->decode($body);
unless ($body && !$json->error) {
$self->
Hash::Storage->new( driver => [ DBI => {
dbh => $dbh,
serializer => 'JSON',
table => 'users',
key_column => 'user_id',
data_column =>
package Net::Semantics3::Products;
use Moose;
use methods;
use JSON::XS;
use Data::Dumper;
use Net::Semantics3::Error;
extends 'Net::Semantics3';
use constant MAX_LIMIT => 10;
=head1 NAME
Net::Se
( 'products' );
=head3 get_query_json( ENDPOINT )
Returns the JSON string of the constructed query for the specified endpoint.
my $productsJSON = get_query_json( 'products' );
=head3 get_resul
get_results( );
=head3 get_results_json( )
Returns the JSON string of the results from any previously executed query.
my $resultsJSONString = get_results_json( );
=head3 clear( )
Clears previ
rks
# http://geocoding.geo.census.gov/geocoder/vintages?benchmark=<id>
# with Accept: application/json
sub query {
my $class = shift;
my %opt = (
returntype => 'geographies',
benchmark =>
use File::Temp (); # tempdir() in _run_mime_helper.
use File::Copy ();
use File::Compare ();
use JSON;
use String::ShellQuote; # used in _prep_configdir
use IPC::Run; # implements File::Unpack::r
bzip2
# ...
$u->unpack("inputfile.tar.bz2");
while ($log =~ m{^\s*"(.*?)":}g) # it's JSON.
{
print "$1\n"; # report all files unpacked
}
...
Most of the known a
0, archive_name_as_dir => 0,
follow_file_symlinks => 0,
log_params => {}, log_type => 'JSON');
Creates an unpacker instance. The parameter C<destdir> must be a writable location; all outpu
a logfile, where freshly unpacked files are reported.
When a logfile is specified, its format is JSON;
default is STDOUT with format PLAIN.
-l --list-helpers
Overview of mime-type patter
Default: skip all symlinks.
}) if $help;
if (defined $opt{logfile})
{
$opt{log_type} = 'JSON';
$opt{logfile} = \*STDOUT if $opt{logfile} eq '-';
}
$opt{logfile} ||= '/dev/null' if $li
ound. (new() opens the logfile, unpack() closese it.)
$u = File::Unpack->new(%opt);
$u->mime_helper_dir(@mime_helper_dirs);
}
}
# delete $u->{json};
# die "$0: " . Dumper $u;
package Net::Semantics3;
use strict;
use warnings;
use Moose;
use methods;
use JSON::XS;
use OAuth::Lite::Consumer;
use Data::Dumper;
use Switch;
use Net::Semantics3::Error;
our $VERSION = '0.1';
);
method _request {
my ( $path, $jsonParams, $verb ) = @_;
switch ($verb) {
case "GET" { return $self->_make_request('GET', $path, $jsonParams); }
case "PUT" { retu
, $path, $jsonParams); }
case "POST" { return $self->_make_request('POST', $path, $jsonParams); }
case "DELETE" { return $self->_make_request('DELETE', $path, $jsonParams);
ore::Response;
#$Id$
use Data::Dumper;
use WebDAO::Response;
use JSON;
use WebDAO;
use base qw( WebDAO::Response );
mk_attr ( __json=>undef, __html=>undef, __xml=>undef);
our $VERSION = '0.1';
use
functionality to return context.
=head1 METHODS
=cut
=head2 json
=cut
sub json : lvalue {
my $self = shift;
$self->{__json};
}
sub raw : lvalue {
my $self = shift;
$self->{__r
$res ;
if ( exists $accept->{'application/javascript'} ) {
$res = $self->json;
$res = to_json($res) unless ref($res) eq 'CODE';
} else {
$res = $self->html
}
Hash::Storage->new( driver => [ DBI => {
dbh => $dbh,
serializer => 'JSON',
table => 'users',
key_column => 'user_id',
data_column =>
PSIS
my $st = Hash::Storage->new(
driver => [ OneFile => { serializer => 'JSON', file => '/tmp/t.json' } ]
);
# Store hash by id
$st->set( 'user1' => { name => 'Viktor', gend
r => 'JSON', file => '/tmp/t.json' } ]
);
$DRIVER - also can be a Hash::Storage driver object
my $drv = Hash::Storage::Driver::OneFile->new({ serializer => 'JSON', file => '/tmp/t.json' });
SIS
my $st = Hash::Storage->new(
driver => [ OneFile => { serializer => 'JSON', file => '/tmp/t.json' } ]
);
# Store hash by id
$st->set( 'user1' => { name => 'Viktor',
=> 'JSON', file => '/tmp/t.json' } ]
);
$DRIVER - also can be a Hash::Storage driver object
my $drv = Hash::Storage::Driver::OneFile->new({ serializer => 'JSON', file => '/tmp/t.json' }
package Mojo::JSON::XS;
use strict;
use warnings;
use base 'Mojo::Base';
use JSON::XS;
use Mojo::ByteStream 'b';
# Literal names
our $FALSE = JSON::XS::false;
our $TRUE = JSON::XS::true;
# Byte
[^\0]\0\0\0" => 'UTF-32LE',
"[^\0]\0[^\0]\0" => 'UTF-16LE'
};
__PACKAGE__->attr('_jsonxs' => sub { JSON::XS->new->convert_blessed(1) });
__PACKAGE__->attr('error');
sub decode {
my ($self
_jsonxs->decode($string);};
if ($@) {
$self->_exception($string, $@);
return;
}
return $result;
}
sub encode {
my ($self, $ref) = @_;
my $string = $self->_jsonx
delete $page->{content};
io("cache/$id.json")->print($self->json->encode($blob));
}
io("cache/page-list.json")->print($self->json->encode($page_list));
$self->make_tag_cloud($b
Experimental support for MYMETA
if ( $ENV{X_MYMETA} ) {
if ( $ENV{X_MYMETA} eq 'JSON' ) {
$self->Meta->write_mymeta_json;
} else {
$self->Meta->write_mymeta_yaml;
}
}
return 1;
}
1;
y
it under the same terms as Perl itself.
Except portions taken from Marc Lehmann's code for the JSON::XS
module, which is licensed under the same terms as this module.
Also except the code for Snap
mpFile('MYMETA.yml', $meta);
}
sub write_mymeta_json {
my $self = shift;
# We need JSON to write the MYMETA.json file
unless ( eval { require JSON; 1; } ) {
return 1;
}
# Generate the data
ta or return 1;
# Save as the MYMETA.yml file
print "Writing MYMETA.json\n";
Module::Install::_write(
'MYMETA.json',
JSON->new->pretty(1)->canonical->encode($meta),
);
}
sub _write_mymeta_da
est::EOL
Test::Version
Test::Kwalitee
MetaTests
Test::CPAN::Meta::JSON
MojibakeTests
Test::NoTabs
PodCoverageTests
PodSyntaxTests
]
[Test::EOL]
[Test::Version]
[Test::Kwalitee]
[MetaTests]
[Test::CPAN::Meta::JSON]
[Test::MinimumVersion]
max_target_perl = 5.008008
[MojibakeTests]
[Test::NoTabs
$jsonxs, $msgpack, $dd_noindent, $dd_indent, $cbor
);
my $storable_tag= "strbl";
my $sereal_tag= "srl";
my %meta = (
jxs => {
enc => '$::jsonxs->encode($data);',
dec => '$::jsonx
);',
name => 'JSON::XS OO',
init => sub {
$jsonxs = JSON::XS->new()->allow_nonref();
},
use => 'use JSON::XS qw(decode_json encode_json);',
},
ddl =
. $x;
},
}
);
}
my %names = (
"JSON::XS" => 'json xs',
"Data::Dumper::Limited" => 'ddl',
"Data::MessagePack"
use strict;
use warnings;
use lib 'lib';
use Test::More;
use JSON::WebToken;
use Crypt::CBC;
use Crypt::OpenSSL::AES;
use Crypt::OpenSSL::RSA;
use Crypt::OpenSSL::Bignum;
use Digest::SHA qw(hmac_sha2