matter::JSON;
use Any::Moose;
with 'Net::OpenSocial::Client::Formatter';
use JSON ();
has '+name' => (
default => q{json},
);
has '+content_type' => (
default => q{application/json},
);
s
self, $obj ) = @_;
my $content = JSON::encode_json($obj);
return $content;
}
sub decode {
my ( $self, $content ) = @_;
my $obj = JSON::decode_json($content);
return $obj;
}
no An
=head1 NAME
Net::OpenSocial::Client::Formatter::JSON - JSON formatter
=head1 SYNOPSIS
my $formatter = Net::OpenSocial::Client::Formatter::JSON->new;
my $request_content = $formatter->encod
ocial::Client::Protocol::RPC->new(
formatter => Net::OpenSocial::CLient::Formatter::JSON->new,
request_builder => Net::OpenSocial::Client::HTTPRequestBuilder::OAuth->new(...),
ype::Format;
use strict;
use warnings;
use base 'Exporter';
our @EXPORT_OK = qw(JSON XML ATOM);
use constant JSON => 0;
use constant XML => 1;
use constant ATOM => 2;
1;
=head1 NAME
Net::OpenS
ants for format-type
=head1 SYNOPSIS
use Net::OpenSocial::Client::Type::Auth qw(JSON XML ATOM);
say JSON;
say XML;
say ATOM;
=head1 DESCRIPTION
Constants for format-type.
But curre
support XML and ATOM format.
=head1 VALUES
=over 4
=item JSON
use JSON encoder/decoder.
See L<Net::OpenSocial::Client::Formatter::JSON> for more detail.
=item XML
use XML encoder/decoder.
Now n
cial::Client::Protocol::REST->new(
formatter => Net::OpenSocial::CLient::Formatter::JSON->new,
request_builder => Net::OpenSocial::Client::HTTPRequestBuilder::OAuth->new(...),
ent::Formatter::JSON;
use Net::OpenSocial::Client::Type::Protocol qw(REST RPC);
use Net::OpenSocial::Client::Type::Auth qw(OAUTH ST);
use Net::OpenSocial::Client::Type::Format qw(JSON XML ATOM);
wit
lt => OAUTH,
);
has 'format_type' => (
is => 'ro',
isa => 'Str',
default => JSON,
);
has 'consumer_key' => (
is => 'ro',
isa => 'Str',
);
has 'consumer_secret' => (
ld_formatter {
my $self = shift;
if ( $self->format_type eq JSON ) {
return Net::OpenSocial::Client::Formatter::JSON->new;
}
# XXX: not supported yet
#elsif ( $self->forma
et::OpenSocial::Client::Type::Auth qw(OAUTH ST);
use Net::OpenSocial::Client::Type::Format qw(JSON XML);
use Net::OpenSocial::Client::Type::Protocol qw(REST RPC);
my $client = Net::OpenSo
ew(
container => $container,
auty_type => OAUTH,
format_type => JSON,
protocol_type => REST,
);
=head3 container
First, you have to prepare L<Net::OpenS
=> q{foobarbuz},
...
);
=head3 format_type
Now it only supports JSON format, so, it sets JSON by default.
=head3 protocol_type
REST or RPC.
REST is set by default.
Make sure th