een XUL and server is based on a simple
JSON based protocol. The following syntax definition tries to
define the protocol. Everything in curly brackets is a JSON object,
strings are quoted and non-ter
$expected_jsync, 'jsync matches what we expected';
=head1 DESCRIPTION
JSON YAML Notation Coding (JSYNC) is an extension of JSON that can serialize
any data objects. Test::JSYNC makes it easy to ver
d_jsync> is provided as an alternative to C<jsync_ok> using the same
naming convention as L<Test::JSON> but is not exported by default.
=head2 jsync_is
Test passes if the two JSYNC strings are valid
me naming
convention as L<Test::JSON> but is not exported by default.
=head1 SEE ALSO
This module uses L<JSYNC> and L<Test::Differences>, and is based on
L<Test::JSON>.
=head1 AUTHOR
Nick Patch <p
, and creates
a representation of the resource. For example, a JSON representation
might just return the result of L<JSON::Any/encode_json>.
=head1 AUTHOR
Oliver Charles
=head1 COPYRIGHT AND LICENS
se strict;
use warnings;
use LWP::UserAgent;
use URI::Escape qw/uri_escape/;
use Digest::SHA;
use JSON::Any;
use vars qw/$errstr/;
sub new {
my $class = shift;
my $args = scalar @_ % 2 ? shif
$args->{ua} = LWP::UserAgent->new(%$ua_args);
}
unless ( $args->{json} ) {
$args->{json} = JSON::Any->new;
}
bless $args, $class;
}
sub errstr { $errstr }
sub getAut
is_success ) {
$errstr = $resp->status_line;
return;
}
return $self->{json}->jsonToObj( $resp->content );
}
sub getUrlMetrics {
my $self = shift;
my $args = scalar @_
se Socket;
use IO::Socket;
use LWP::Simple qw(get);
use URI::Escape qw(uri_escape);
use JSON qw(to_json from_json);
use Data::Dumper;
# get commandline arguments
my ($ModulesPath, $Port) = @ARGV;
#
else {
$data{"_method"} = "ERROR";
}
# analyse request and create answer
my $info = from_json($data{'data'});
#print STDERR Dumper($info);
my $quit = 0;
$quit = 1 if exists $info->{'ev
t "Content-type: application/json", Socket::CRLF;
print $client "Content-type: text/html", Socket::CRLF;
print $client Socket::CRLF;
print $client ((($answer && to_json($answer)) || '{"action":"non
mmon::Numeric qw/PositiveInt SingleDigit/;
use WWW::Mechanize;
use URI::QueryParam;
use URI;
use JSON;
has 'mechanize' => (
is => 'ro',
isa => 'WWW::Mechanize',
lazy => 1,
redicate => 'has_results' );
has 'output' => ( is => 'ro', isa => NonEmptySimpleStr, default => 'json' );
=head2 url_builder
Build the URL to do the "get" with all arguments that you pass
for the a
rch
Make the search, and decode the JSON, if don't have the attribute
"query", it return nothing.
=cut
sub get_search {
my $self = shift;
my $json = JSON->new->allow_nonref;
# if haven
ckage Geo::Coder::RandMcnally;
use strict;
use warnings;
use Carp qw(croak);
use Encode ();
use JSON;
use LWP::UserAgent;
use URI;
our $VERSION = '0.01';
$VERSION = eval $VERSION;
sub new {
my
return unless $res->is_success;
# Change the content type of the response from 'application/json' so
# HTTP::Message will decode the character encoding.
$res->content_type('text/plain');
my $content = $res->decoded_content;
return unless $content;
my $data = eval { from_json($content) };
return unless $data;
my @results = @{ $data->{geocodedLocation} || [] };
}
},
"formats" : [
"json",
"xml"
]
}'
);
has api
ift;
Net::HTTP::Spore->new_from_strings($self->specification)
->enable('Format::JSON')->enable('Runtime');
}
);
has session_id => (
is => 'ro',
lazy => 1,
is
t;
my $attrs = shift;
$attrs->{api_key} = $self->api_key;
$attrs->{format} = 'json';
$attrs->{session_id} = $self->session_id
if ($self->_need_session($method));
retu
odule::Install::JSONMETA;
use Module::Install::Base;
BEGIN {
our @ISA = qw(Module::Install::Base);
our $ISCORE = 1;
our $VERSION = '7.001';
}
=head1 NAME
Module::Install::JSONMETA - (depreca
ite META.json instead of META.yml
=head1 ACHTUNG
B<Achtung!> This library will soon be obsolete as EUMM moves to use the
official L<CPAN::Meta::Spec> JSON files.
=cut
our $json;
sub jsonmeta {
my ($self) = @_;
unless (eval { require JSON; JSON->VERSION(2); 1 }) {
die "could not load JSON.pm version 2 or better; can't use jsonmeta\n"
if $self->is_admin;
return; # Not admin,
package ExtUtils::MakeMaker::JSONMETA;
our $VERSION = '7.001';
use ExtUtils::MM_Any;
use JSON 2;
=head1 NAME
ExtUtils::MakeMaker::JSONMETA - (deprecated) write META.json instead of META.yml
=head1
ial L<CPAN::Meta::Spec> JSON files.
In your Makefile.PL:
use ExtUtils::MakeMaker;
eval { require ExtUtils::MakeMaker::JSONMETA; };
WriteMakefile(...);
If EU::MM::JSONMETA cannot be loaded (f
talling your module does not have it or JSON installed), things will
continue as usual. If it can be loaded, a META.json file will be produced,
containing JSON.
=cut
no warnings qw(once redefine);
NIVERSAL::require;
our $VERSION = '0.06';
use URI;
use URI::QueryParam;
use LWP::UserAgent;
use JSON;
use WebService::Bitly::Result::HTTPError;
use base qw(Class::Accessor::Fast);
__PACKAGE__->mk
name);
$url->query_param(apiKey => $self->user_api_key);
$url->query_param(format => 'json');
my $response = $self->ua->get($url);
if (!$response->is_success) {
return We
ice::Bitly::Result::' . $result_class;
$result_class->require;
my $bitly_response = from_json($response->content);
return $result_class->new($bitly_response);
}
sub _api_url {
my ($s
, $class;
my ( $json, $error, $http_code ) = @_;
$self->{http_code} = $http_code;
$self->{error} = $error;
my $answer = WebService::Blekko::my_decode_json( $json ); # XXX needs eval
Blekko JSON APIs
=cut
use strict;
use warnings;
no warnings qw( uninitialized );
use LWP::UserAgent;
use LWP::Protocol;
use HTTP::Request;
use List::Util qw( min );
use Time::HiRes;
use JSON;
use
$url = sprintf( $template, $self->{scheme}, $self->{server},
urlencode( "/json $q" ), $self->{auth}, $self->{source}, $ps, $p );
my $req = HTTP::Request->new( 'GET', $url
->new( '', "http failure, code is ".$resp->code, $resp->code );
}
my $answer = my_decode_json( $resp->content ); # XXX does this need an eval?
if ( defined $answer->{status} && $answer->
package NRD::Serialize::plain;
use strict;
use warnings;
use JSON;
use base 'NRD::Serialize';
sub new {
my ($class, $options) = @_;
$options = {} if (not defined $options);
my $self = {
0 }
sub helo {
return undef;
}
sub unfreeze {
my ($self, $recieved) = @_;
return decode_json($recieved);
}
sub freeze {
my ($self, $result) = @_;
return encode_json($result);
}
1;
gs;
use POE::Component::Client::HTTP;
use HTTP::Request::Common;
use Algorithm::FloodControl;
use JSON::Any;
use Class::MOP;
use Module::Pluggable search_path => ['POE::Component::Github::Request'], e
ault => 'github.com/api/v2/json',
);
has _http_alias => (
is => 'rw',
isa => 'Str',
default => '',
);
has 'json' => (
is => 'ro',
isa => 'JSON::Any',
lazy => 1,
default => sub {
return JSON::Any->new;
}
);
has _requests => (
is => 'ro',
default => sub { { } },
);
has _shutdown => (
is => 'rw',
default => 0,
);
sub spawn {
shif
sa => 'Str', default => '' );
# api
has 'api_url' => ( is => 'ro', default => 'github.com/api/v2/json/');
has 'scheme' => ( is => 'ro', default => 'http://');
has 'auth_scheme' => ( is => 'ro', d
lekko::QueryResult;
sub new
{
my $class = shift;
my $self = bless {}, $class;
my ( $json, $http_code ) = @_;
$self->{http_code} = $http_code;
if ( $http_code !~ /^2/ )
{
->{total_num} = 0;
return $self;
}
my $answer = WebService::Blekko::my_decode_json( $json );
$self->{raw} = $answer;
if ( defined $answer->{ERROR} )
{
# {suggest
shift;
print { $self->{outfh} } <<'END';
htrepl commands:
.header Content-Type application/json # set header
.header Content-Type # remove header
.cookie ID 12345
XML;
use Encode qw(encode);
use YAML qw(Dump);
use JSON qw();
use File::Path qw(mkpath);
__PACKAGE__->mk_accessors(qw(to_xml to_hash to_yaml to_json from_xml));
our $VERSION = '1.0.0';
# Default va
my $hash = $self->to_hash(%args);
return YAML::Dump($hash);
}
=head2 to_json( ... )
Export the Augeas tree to JSON.
=over
=item path
C<path> is the Augeas path to export. If ommitted, it wi
from the export.
=back
=cut
sub to_json {
my $self = shift;
my %args = @_;
my $hash = $self->to_hash(%args);
my $json = new JSON;
return $json->encode($hash);
}
=head2 from_xml(
Reaction::InterfaceModel::Search::Spec;
use Reaction::Role;
use Method::Signatures::Simple;
use JSON;
use Scalar::Util qw(weaken);
use namespace::clean -except => [ qw(meta) ];
has '_search_spec' =
all_attributes;
return to_json(\%val, { canonical => 1 });
}
requires '_from_string_unpack_value';
method from_string ($class: $string, $other) {
my %raw = %{from_json($string)};
my %val;
@v