til::JSON - JSON utility functions
=head1 DESCRIPTION
This is just a wrapper around a singleton JSON object, ensuring that everywhere
we deal with JSON we do it in a consistent way.
We use JSON::An
g JSON libraries
from CPAN.
=cut
package WebService::TypePad::Util::JSON;
use strict;
use warnings;
use JSON::Any;
use Exporter 'import';
our @EXPORT = qw(json_encode json_decode json_true json_f
$json = JSON::Any->new();
=pod
=head2 json_encode($ref)
Given some JSON-able reference (usually a HASH ref), return a JSON string.
=cut
sub json_encode {
my ($value) = @_;
return $json->
kage WebService::TypePad::Util::Coerce;
use strict;
use warnings;
use WebService::TypePad::Util::JSON;
use WebService::TypePad::Object;
use Set::Tiny;
# Primitive Types
sub coerce_string_in {
r
lean_in {
return defined($_[0]) ? ($_[0] ? json_true() : json_false()) : undef;
}
sub coerce_boolean_out {
return defined($_[0]) ? ($_[0] == json_true() ? 1 : 0) : undef;
}
# Collection type
sub {
my ($obj) = @_;
return undef unless defined($obj);
return $obj->_as_json_dictionary;
};
foreach my $type (keys %WebService::TypePad::Object::Object_Types) {
$self->{data} = {};
map { $self->$_($params{$_}) } keys %params;
return $self;}
sub _from_json_dictionary {
my ($class, $dict) = @_;
if (my $object_types = $dict->{objectTypes}) {
}
}
my $self = $class->new();
$self->{data} = $dict;
return $self;}
sub _as_json_dictionary {
return $_[0]->{data};
}
1;
=head1 NAME
WebService::TypePad::Object - Base clas
;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Multi;
use WebService::TypePad::Util::JSON;
use Net::OAuth;
BEGIN {
eval { require Math::Random::MT };
unless ($@) {
Math:
up or the user.
my $url = $self->{api}->backend_url() . join('/', @{$task->path_chunks}) . '.json';
my $method = $task->method;
my $req = HTTP::Request->new($method => $url);
if (my
my $json_body = json_encode($body);
$req->header('Content-Type' => 'application/json');
$req->header('Content-Length' => length($json_body));
$req->content($json_bo