.w3.org/2001/XMLSchema#date'; }
return 'http://www.w3.org/2001/XMLSchema#dateTime';
}
sub TO_JSON
{
return "$_[0]";
}
1;
__END__
=head1 BUGS
Please report any bugs to L<http://rt.cpan.org/>.
:Types::ISO8601 qw/ ISO8601DateTimeStr /;
use MooseX::Types::DateTime qw/ DateTime /;
use JSON qw/ encode_json /;
use namespace::autoclean;
our $VERSION = '0.003';
$VERSION = eval $VERSION;
with 'Me
|| 'none',
'@message' => exists($data->{message}) ? delete($data->{message}) : encode_json($data),
'@fields' => $data,
},
exists($data->{uuid}) ? ( id => delete
roformats::DocumentContext;
use HTML::Microformats::Datatype;
use HTML::Microformats::Format;
use JSON;
use RDF::Trine 0.130;
use XML::LibXML;
use Object::AUTHORITY;
BEGIN {
$HTML::Microformats::AU
= shift;
$self->parse_microformats;
return $self->{'objects'};
}
sub TO_JSON
{
return $_[0]->all_objects;
}
sub json
{
my $self = shift;
my %opts = @_;
$opts{'convert_blessed'} = 1
unles
defined $opts{'convert_blessed'};
$opts{'utf8'} = 1
unless defined $opts{'utf8'};
return to_json($self->all_objects, \%opts);
}
sub model
{
my $self = shift;
my $model = RDF::Trine::Model->
ne::Node::Literal->new($self->to_string, undef, $self->datatype),
));
return $self;
}
sub TO_JSON
{
my $self = shift;
return $self->to_string;
}
1;
__END__
=head1 BUGS
Please report any bug
[], ref $proto || $proto;
}
}
sub sub_nil
{
my $obj = shift;
sub { $obj };
}
sub TO_JSON
{
return {};
}
sub AUTOLOAD
{
unless ( defined wantarray ) # don't bother doing more
ds + ($self->{d}->nanoseconds / 1000000000)).'S'; }
$str =~ s/T$//;
return $str;
}
sub TO_JSON
{
my $self = shift;
return $self->to_string;
}
=item C<< $d->datatype >>
Returns an the RDF d
no warnings;
use 5.010;
use HTML::Microformats::Utilities qw(stringify xml_stringify);
use JSON qw/to_json/;
use Object::AUTHORITY;
BEGIN {
$HTML::Microformats::Format::XOXO::AUTHORITY = 'cpan:TO
(
$self->id(1),
RDF::Trine::Node::Resource->new('http://open.vocab.org/terms/json'),
$self->_make_literal( to_json($self, {canonical=>1,convert_blessed=>1}) ),
));
return $self;
}
sub profi
s, HTML::Microformats::Format::XOXO::LI->parse($li, $xoxo); }
bless \@items, $class;
}
sub TO_JSON
{
return [ @{$_[0]} ];
}
sub as_array
{
my ($self) = @_;
return wantarray ? @$self : $self;
}
View>
The base class, which creates a view of the application.
The result can be represented in JSON, XML and HTML.
L<XML::LibXSLT> is used to generate HTML.
=item L<Ambrosia::Validator>
The class
package Net::OpenStack::Compute::AuthRole;
use Moose::Role;
use JSON qw(from_json to_json);
requires qw(
auth_url
user
password
project_id
region
service_name
is_rax_auth
content_type => 'application/json', content => to_json($auth_data));
die $res->status_line . "\n" . $res->content unless $res->is_success;
my $data = from_json($res->content);
my $token
:Zilla::Role::BeforeRelease';
use Encode qw(encode_utf8);
use LWP::UserAgent;
use version ();
use JSON::PP;
# Lots of this is cargo-culted from DZP::CheckPrereqsIndexed
sub before_release {
my (
->get("http://cpanidx.org/cpanidx/json/mod/$pkg");
if ($res->is_success) {
my $yaml_octets = encode_utf8($res->decoded_content);
my $payload = JSON::PP->new->decode($yaml_octets);
rnings;
use Data::MessagePack;
use JSON;
use Storable;
use Benchmark ':all';
my $a = do 'benchmark/data.pl';
print "-- serialize\n";
print "$JSON::Backend: ", $JSON::Backend->VERSION, "\n";
print "D
";
print "Storable: $Storable::VERSION\n";
cmpthese timethese(
-1 => {
json => sub { JSON::encode_json($a) },
storable => sub { Storable::freeze($a) },
mp => sub
package WWW::Socrata;
use strict;
use warnings;
use WWW::Curl::Easy;
use JSON;
use URI::Escape;
use Carp;
our $VERSION = '0.02';
sub new {
my $class = shift;
my $rh_params = shift;
my $self = {}
path;
#define default headers to send
my @headers = (
'Accept: application/json',
'Content-type: application/json',
"X-App-Token: " . $self->{app_token},
);
#define parameters
my $qstring
i++){
shift @response;
}
$response_body = join("\n", @response);
$obj_response = decode_json($response_body);
return $obj_response;
} else {
croak "An error happened: " . $curl->strerro
ings;
use strict;
use Vimana;
use Vimana::Util;
use JSON::PP;
use File::Path;
use Digest::MD5 qw(md5_hex);
use YAML;
sub new_json {
return JSON::PP->new->allow_singlequote(1);
}
sub record_dir {
open FH , "<" , $record_file;
local $/;
my $json = <FH>;
close FH;
my $record;
eval { $record = new_json()->decode( $json ) };
if( $@ ) {
# try to load YAML. (old r
$pkgname );
return 0 if -f $record_file;
open FH , ">" , $record_file;
print FH new_json()->encode( $record );
close FH;
#return YAML::DumpFile( $record_file , $record );
}
rialization format.
It enables to exchange structured objects between many languages like JSON.
But unlike JSON, it is very fast and small.
=head2 ADVANTAGES
=over 4
=item PORTABLE
The MessagePack
does not depend on language nor byte order.
=item SMALL IN SIZE
say length(JSON::XS::encode_json({a=>1, b=>2})); # => 13
say length(Storable::nfreeze({a=>1, b=>2})); # => 21
say
se.)
-- serialize
JSON::XS: 2.3
Data::MessagePack: 0.24
Storable: 2.21
Benchmark: running json, mp, storable for at least 1 CPU seconds...
json: 1 wallclock secs ( 1.00
;
use Data::MessagePack;
use JSON;
use Storable;
use Benchmark ':all';
#$Data::MessagePack::PreferInteger = 1;
my $a = do 'benchmark/data.pl';
my $j = JSON::encode_json($a);
my $m = Data::MessagePa
nt "$JSON::Backend: ", $JSON::Backend->VERSION, "\n";
print "Data::MessagePack: $Data::MessagePack::VERSION\n";
print "Storable: $Storable::VERSION\n";
cmpthese timethese(
-1 => {
json
=> sub { JSON::decode_json($j) },
mp => sub { Data::MessagePack->unpack($m) },
storable => sub { Storable::thaw($s) },
}
);
ON = '0.2.1';
use v5.10;
use open qw(:std :utf8);
use Moose;
use MooseX::Types::Path::Class;
use JSON;
use LWP::UserAgent;
use HTTP::Cookies;
use Log::Any qw//;
use DateTime;
use MIME::Base64 qw//;
u
=> 1,
);
method _build__ua {
my $headers = HTTP::Headers->new(Content_Type => 'application/json',);
# XXX is it worth saving cookie?? How is password more valuable than auth token?
# l
ogger->error('Network: ' . $response->status_line);
return;
}
my $index = decode_json($response->content);
if ($index->{count} > 0) {
$self->logger->debugf('Network: Inde
verters
=head3 L<DataFlow::Proc::MessagePack> 1.112100
No tests yet!!
=head3 L<DataFlow::Proc::JSON> 1.112100
No tests yet!!
=head3 L<DataFlow::Proc::YAML> 1.112100
No tests yet!!
=head3 L<Data
my $res = LWP::UserAgent->get('http://servers.example.com/api/hosts');
my $hosts = decode_json $res->content;
$hosts;
}, {
deploy_to => "/home/app/www/$application",
bra
my $res = LWP::UserAgent->get('http://servers.example.com/api/hosts');
my $hosts = decode_json $res->content;
$hosts;
};
# or
role production => 'production.example.com', {
number of purposes, but the
principle intention is to make MARC data amenable to serializing into
JSON, YAML, etc. Field and subfield order is preserved. Multiple
instances of either are also allowed.
ed by Frederic Demians' MARC::Moose::Formater::JSON.
Format inspired by http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json
=head1 AUTHOR
Clay Fouts <cfouts@khephera.n
y $length = do { no warnings; use bytes; length $http_body; };
$r->content_type('application/json');
$r->headers_out->{'Content-Length'} = $length;
$r->print($http_body);
return Apa