o install YAML or JSON just to run some of the Badger
tests) and to support some legacy systems that use data encoded in this way
(mostly dating back to the days before YAML and JSON were around). If
you're
starting out afresh then you're probably better off using YAML or JSON unless
you have good reason not to.
The syntax is similar to Perl in that it uses single quotes for literal
strings, squa
:> as a delimiter between hash keys and values,
thus providing an overlap with a useful subset of JSON syntax:
{
message: 'Hello World, this is some text',
things: ['a list' 'of s
ue::Set;
use Moose;
extends 'Net::Fluidinfo::Value::Native';
sub to_json {
my $self = shift;
my @strings = map $self->json->encode("$_"), @{$self->value};
'[' . join(',', @strings) . ']'
},
headers => $fin->accept_header_for_json,
on_success => sub {
my $response = shift;
my $h = $class->json->decode($response->content);
$class->
h
);
}
);
}
sub update {
my $self = shift;
my $payload = $self->json->encode({policy => $self->policy, exceptions => $self->exceptions});
$self->fin->put(
path),
query => { action => $self->action },
headers => $self->fin->headers_for_json,
payload => $payload
);
}
no Moose;
no MooseX::ClassAttribute;
__PACKAGE__->meta->ma
ckage Net::Fluidinfo::Value::Boolean;
use Moose;
extends 'Net::Fluidinfo::Value::Native';
sub to_json {
my $self = shift;
$self->value ? 'true' : 'false';
}
no Moose;
__PACKAGE__->meta->make
package Net::Fluidinfo::Value::Null;
use Moose;
extends 'Net::Fluidinfo::Value::Native';
sub value {
undef;
}
sub to_json {
'null';
}
no Moose;
__PACKAGE__->meta->make_immutable;
1;
MooseX::ConfigFromFile";
use JSON 2.0;
sub get_config_from_file {
my($file) = @_;
open my $fh, "<", $file or confess "open: $file: $!";
local $/;
my $json = <$fh>;
close $fh or di
e "close: $file: $!";
return JSON->new->relaxed->utf8->decode($json);
}
}
use Data::Munge;
use IO::File;
use IPC::Run ();
use Term::ReadKey ();
use Term::ReadLine;
use Text::Balanced ();
use Try
luidinfo::Value';
use Carp;
use Net::Fluidinfo::JSON;
use MooseX::ClassAttribute;
class_has json => (is => 'ro', default => sub { Net::Fluidinfo::JSON->new });
# In the future more serialisation for
ddb.value+json';
sub mime_type {
$MIME_TYPE;
}
sub is_mime_type {
my ($class, $mime_type) = @_;
defined $mime_type && $mime_type eq $MIME_TYPE;
}
sub new_from_fin_type_and_json {
my
($class, $fin_type, $json) = @_;
my $native_class = $class->class_for_fin_type($fin_type);
$native_class->new(value => $class->json->decode($json));
}
# Fluidinfo types of native values are
se Moose;
extends 'Net::Fluidinfo::Value::Native';
sub to_json {
my $self = shift;
no warnings; # value may be undef
$self->json->encode('' . $self->value);
}
no Moose;
__PACKAGE__->meta
Strings;
use Moose;
extends 'Net::Fluidinfo::Value::Native';
sub to_json {
my $self = shift;
my @strings = map $self->json->encode("$_"), @{$self->value};
'[' . join(',', @strings) . ']';
= 'fluiddb.fluidinfo.com';
our $SANDBOX_HOST = 'sandbox.fluidinfo.com';
our $JSON_CONTENT_TYPE = 'application/json';
has protocol => (is => 'rw', isa => 'Str', default => $DEFAULT_PROTOCOL);
has
s_for_json {
return {
'Accept' => $JSON_CONTENT_TYPE,
'Content-Type' => $JSON_CONTENT_TYPE
};
}
sub accept_header_for_json {
return {
'Accept' => $JSON_CONTE
NT_TYPE
}
}
sub content_type_header_for_json {
return {
'Content-Type' => $JSON_CONTENT_TYPE
}
}
#
# -- Convenience shortcuts ----------------------------------------------------
; # internal package, defined below
1;
package Net::OpenSRS::OMA;
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use Carp;
our $VERSION = "0.02";
$VERSION = eval $VERSION;
=head1 NAME
Ne
s module requires these modules.
=over
=item LWP::UserAgent
=item LWP::Protocol::https
=item JSON
=back
=head1 CAVEAT
This API is still under development and thus the
method calls, arguments
ds. All methods take a hash argument, that hash has
a credentials hashref added, is converted to JSON and sent to the API. Method calls return a
Net::OpenSRS::OMA::Response object containing the res
my $self = shift;
my $payload = $self->json->encode({
description => $self->description,
indexed => $self->as_json_boolean($self->indexed),
name => $se
ders => $self->fin->headers_for_json,
payload => $payload,
on_success => sub {
my $response = shift;
my $h = $self->json->decode($response->content);
ts,
headers => $fin->accept_header_for_json,
on_success => sub {
my $response = shift;
my $h = $class->json->decode($response->content);
my $t =
ooseX::Types::DateTime;
# ABSTRACT: Perl wrapper for talking with Bullfinch
use Data::UUID;
use JSON::XS;
use Memcached::Client;
use Net::Bullfinch::Iterator;
has '_client' => (
is => 'rw',
onal => 1 }
);
my ($rname, $json) = $self->_prepare_request($data, $queuename, $trace, $procby);
my $kes = $self->_client;
$kes->set($queue, $json, $expire);
my @items = ();
if(defined($resp)) {
$kes->get($rname.'/close');
my $decoded = decode_json($resp);
if(exists($decoded->{EOF})) {
last;
}
package WebService::Linode::Base;
use warnings;
use strict;
use Carp;
use JSON;
use LWP::UserAgent;
use Data::Dumper;
=head1 NAME
WebService::Linode::Base - Perl Interface to the Linode.com API.
if ($response->content =~ m|ERRORARRAY|i) {
my $json = from_json($response->content);
if (scalar (@{$json->{ERRORARRAY}}) == 0) {
return $json->{DATA};
} else {
# TODO this only returns t
API
my $msg = "API Error " .
$json->{ERRORARRAY}->[0]->{ERRORCODE} . ": " .
$json->{ERRORARRAY}->[0]->{ERRORMESSAGE};
$self->_error(
$json->{ERRORARRAY}->[0]->{ERRORCODE},
$
r::VERSION = '0.05';
}
use Moose;
# ABSTRACT: A way to iterator over results from Bullfinch
use JSON::XS;
use Net::Bullfinch;
with 'Data::Stream::Bulk::DoneFlag';
has 'bullfinch' => (
is
fined $resp ) {
$kestrel->confirm( $resp_queue, 1 );
my $decoded = decode_json( $resp );
if ( exists $decoded->{'EOF'} ) {
$self->_set_done;
fined $resp ) {
$kestrel->confirm( $resp_queue, 1 );
my $decoded = decode_json( $resp );
if ( exists $decoded->{'EOF'} ) {
last;
}
:Native->is_mime_type($mime_type)) {
Net::Fluidinfo::Value::Native->new_from_fin_type_and_json($fin_type, $content);
} else {
# instead of ordinary use(), to play nice with inherit
e),
headers => $fin->accept_header_for_json,
on_success => sub {
my $response = shift;
my $h = $class->json->decode($response->content);
my $user
_about ? $self->json->encode({about => $self->about}) : undef;
$self->fin->post(
path => $self->abs_path('objects'),
headers => $self->fin->headers_for_json,
paylo
payload,
on_success => sub {
my $response = shift;
my $h = $self->json->decode($response->content);
$self->_set_id($h->{id});
# Unset tag paths
ts,
headers => $fin->accept_header_for_json,
on_success => sub {
my $response = shift;
my $h = $class->json->decode($response->content);
my $o =
package Net::Fluidinfo::Base;
use Moose;
use JSON::XS;
use Carp;
use MooseX::ClassAttribute;
class_has json => (is => 'ro', default => sub { JSON::XS->new->utf8->allow_nonref });
has fin => (is =>
ub true {
shift->as_json_boolean(1);
}
sub false {
shift->as_json_boolean(0);
}
sub as_json_boolean {
my ($receiver, $flag) = @_;
$flag ? JSON::XS::true : JSON::XS::false;
}
sub get
};
sub _netloc { 'www.2checkout.com:443' };
enum 'Format' => qw( XML JSON );
class_type 'LPW::UserAGent';
has ua => (
is => 'ro',
isa => 'LWP::UserAgent',
lazy