package Osgood::Client;
use Moose;
use HTTP::Request;
use JSON::XS;
use LWP::UserAgent;
use Moose::Util::TypeConstraints;
use Osgood::EventList;
use Osgood::Event;
use URI;
subtype 'Osgood.Client.UR
$req->content_type('application/json');
$req->content($self->list->freeze);
my $res = $ua->request($req);
if($res->is_success) {
my $data = JSON::XS->new->decode($res->content);
if(!defined($data) || !(ref($data) eq 'HASH')) {
$self->error('Unable to parse JSON response');
return 0;
}
my $count = $data->{count};
if($data-
x => 5,
y => 6,
);
or
$response = $client->photos->add_tag( tags => $json_serialized );
C<tag_text> is ignored if C<tag_uid> is set.
=item create_album( name => $name, l
my ( $format, $parse ) = ( $self->base->format, $self->base->parse );
$self->base->format('JSON');
$self->base->parse(0);
$token = $self->base->call( 'auth.createToken', @_ );
$tok
my ( $format, $parse ) = ( $self->base->format, $self->base->parse );
$self->base->format('JSON');
$self->base->parse(1);
my $resp = $self->base->call( 'auth.getSession', auth_token =>
ironment variables.
=head1 DEPENDENCIES
=over 4
=item L<LWP::UserAgent>
Not in CORE
=item L<JSON>
Not in CORE
=back
=head1 INCOMPATIBILITIES
None reported.
=head1 BUGS AND LIMITATIONS
No
acebook API:
$response = $client->connect->get_unconnected_friends_count(
format => $json,
);
=item register_users( %params )
The connect.registerUsers method of the Facebook API:
e MooseX::AttributeHelpers;
use MooseX::Iterator;
use MooseX::Storage;
with Storage('format' => 'JSON', 'io' => 'File');
has 'events' => (
metaclass => 'Collection::Array',
is => 'rw',
i
name: $@\n" if not $namespace;
}
our %attributes = (
parse => 1,
format => 'JSON',
debug => 0,
throw_errors => 1,
api_version => '1.0',
apps_uri => 'h
arams .= "&$_=$params{$_}";
}
}
return $params;
}
sub _parser {
my $parser = JSON::Any->new;
$parser->handler->allow_nonref;
return $parser;
}
sub _parse {
my ( $sel
# Only load JSON::Any if we haven't already. Lets the developers
# pick their choice of JSON modules (JSON::DWIW, for example)
## no critic
eval q{use JSON::Any};
ironment variables.
=head1 DEPENDENCIES
=over 4
=item L<LWP::UserAgent>
Not in CORE
=item L<JSON>
Not in CORE
=back
=head1 INCOMPATIBILITIES
None reported.
=head1 BUGS AND LIMITATIONS
No
ams);
my $data = $self->mapper->get("$url") || return;
my $res = eval { $self->_json->decode($data) };
my $node = $res->{nodes}->{$page} || {};
my $rss = $node->{att
package Net::Social::Mapper::Persona;
use strict;
use JSON::Any;
=head1 NAME
Net::Social::Mapper::Persona - an object representing an internet persona
=head1 SYNOPSIS
See C<Net::Social::Mapper>
m );
my $page = $self->mapper->get("$url") || return ();
my $info = eval { $self->_json->decode($page) } || return ();
my @personas;
foreach my $url (keys %$info) {
a->{$name} = $attributes->{$key};
}
return $persona;
}
sub _json {
my $self = shift;
return $self->{_json} ||= JSON::Any->new;
}
sub _elsewhere_param {
my $self = shift;
retu
package Net::Social::Mapper::SiteMap;
use strict;
use JSON::Any;
=head1 NAME
Net::Social::Mapper::SiteMap - information about know services around the internet
=head1 SYNOPSIS
my $sitemap = N
A;
my $off = tell($fh);
my $json = JSON::Any->new;
my $data = do { local $/; <$fh> };
seek($fh, $off, 0);
return $self->{_sitemap} ||= $json->decode($data);
}
=head2 profile <se
ona::Flickr;
use strict;
use base qw(Net::Social::Mapper::Persona::Generic);
use Feed::Find;
use JSON::Any;
use URI;
use Data::Dumper;
our $FLICKR_API_KEY = 'efe286838b28127e10271d239dec10bf';
=hea
$params{api_key} = $self->{_flickr_api_key} || $FLICKR_API_KEY;
$params{format} = 'json';
$params{nojsoncallback} = 1;
my $url = URI->new("http://www.flickr.com/services/res
t/");
$url->query_form(%params);
my $page = $self->mapper->get("$url") || return;
return eval { $self->_json->decode($page) };
}
1;
ule::Setup::Plugin::Site::GitHub;
use strict;
use warnings;
use base 'Module::Setup::Plugin';
use JSON;
use LWP::UserAgent;
sub register {
my($self, ) = @_;
$self->add_trigger( before_dump_co
, __PACKAGE__, $Module::Setup::VERSION),
cookie_jar => +{},
);
my $res = $ua->post(
'https://github.com/api/v2/json/repos/create' => \%args
);
$res->is_success;
}
1;
as JSON:
{"br":null}
{"body":{"class":"episode"}}
{"strong":"important content"}
{"a":{"href":"/foo","$":"Link to foo"}}
Note the last two lines. If a tag contains attributes, the JSON val
ue
will be a hash containing those attributes. If a tag doesn't contain
attributes, the JSON value will be either null or a string. If a tag
contains both attributes and a string value, the string w
is converted to a "$" in the JSON/YAML
serialisations, eg:
TAG("po:microsite", "rdf:resource" => "/foo");
As XML:
<po:microsite rdf:resource="/foo"/>
And as JSON:
{"po$microsite":{"rdf$res
html' },
'ics' => { content_type => 'text/calendar', layout => 0 },
'json' => { content_type => 'application/json', layout => 0 },
'mp' => { content_type => 'text/html' },
'ram' =>
handler-coderef is optional. For
example:
respond_to('html', 'txt', 'xml' => \&xml_handler, 'json');
Once a format is selected (TODO, document this) the handler is then invoked;
if no handler wa
tribution tarball is created from.
=head3 distmeta
Creates the F<META.json> file that describes the distribution.
F<META.json> is a file containing various bits of I<metadata> about the
distributio
e
distribution. This file is created as F<META.json> in JSON format.
It is recommended that the C<JSON> module be installed to create it.
If the C<JSON> module is not installed, an internal module su
o write the META.json file, and this
will most likely be fine.
F<META.json> file must also be listed in F<MANIFEST> - if it's not, a
warning will be issued.
The format of F<META.json> file is based
on server response.
=head3 ax_mapping
mapping of recieve values with your application fields in json format.
=cut
__PACKAGE__->mk_accessors(qw(ax_mapping ax_values ax_param));
sub init {
my $
~ /^(xml|atom|rss)$/) {
return $self->to_xml();
} elsif ($format eq 'json') {
return $self->to_json();
} elsif ($format eq 'yaml') {
return $self->to_yaml();
} elsi
html();
} else {
croak "Unsupported format";
}
}
sub to_json
{
my ($self) = @_;
return '{' . _to_json(@{$self->{raw}}) . '}';
}
sub to_yaml
{
my ($self) = @_;
retur
{
my ($self) = @_;
return "<?xml version=\"1.0\"?>\n" . _to_xml(@{$self->{raw}});
}
## JSON with HTML syntax highlighting
sub to_html
{
my ($self) = @_;
return "<!DOCTYPE html PUBL
action
Creates local user if non-existant and redirects to OpenID auth URL
=cut
use Jifty::JSON qw /jsonToObj/;
sub take_action {
my $self = shift;
my $openid = $self->argument_value('op
delayed_return => 1
);
Jifty->web->session->set(ax_mapping => jsonToObj($ax_mapping));
Jifty->web->session->set(ax_values => $ax_values);
$ax_param = '&'.$a
n your system:
./Build dist --gzip=gzip --tar=tar
% Deleting META.json
% Creating META.json
% Creating Task.Joose.Stable-3.04
% Creating Task.Joose.Stable-3.04.tar.gz