1;
}
1;
=pod
=head1 TO DO
- Add the testing dependency algorithm variant
- Add support for JSON META.yml files
=head1 SUPPORT
Bugs should be reported via the CPAN bug tracker at
L<http://rt.
ShareDir ();
use File::UserConfig ();
use Mirror::JSON ();
use LWP::Online ();
use JSAN::Index ();
use JSAN::Client ();
use JSON ();
our $VERSION = '2.04';
$VERSIO
ig}->{mirror} ) {
$self->_print("Locating closest JSAN mirror...");
my $mirror_yaml = Mirror::JSON->read( MIRROR_INIT );
my @mirrors = $mirror_yaml->mirrors;
my $mirror = $mirrors[ int rand s
,
);
}
$self;
}
sub config_file {
File::Spec->catfile($_[0]->{configdir}, 'config.json')
}
sub read_config {
my $self = shift;
my $filename = $self->config_file;
tion';
use strict;
use warnings;
use CGI;
use Config::Tiny;
use DBI;
use HTML::Template;
use JSON::XS;
our $VERSION = '1.04';
# -----------------------------------------------
sub build_search
-> log("Filter returned @{[scalar @$output]} results");
$self -> log('Leaving search');
return JSON::XS -> new() -> encode({results => $output});
} # End of search.
# ----------------------------
=head1 NAME
C<CGI::Application::Demo::Ajax> - A search engine using CGI::Application, AJAX and JSON
=head1 Synopsis
Either:
#!/usr/bin/perl
use CGI::Application::Demo::Ajax;
CGI::Applicatio
package App::Office::Contacts::Import::vCards::View::vCards;
use JSON::XS;
use Moose;
extends 'App::Office::Contacts::View::Base';
use namespace::autoclean;
our $VERSION = '1.12';
# ------------
-----
sub format
{
my($self, $output) = @_;
$self -> log(debug => 'Entered format');
return JSON::XS -> new -> utf8 -> encode({results => [@$output]});
} # End of format.
# -------------------
ber without any
quotes on it in JSON-RPC.
=item double
A floating-point number. Translates to C<< <double> >> in XML-RPC and
a number without any quotes on it, in JSON-RPC. (Note, though, that
numbe
>> in XML-RPC and
a quoted string in JSON-RPC.
=item boolean
A true or false value. Translates to C<< <boolean> >> in XML-RPC,
with a C<0> or C<1> value. In JSON-RPC, translates to C<true> or
C<fals
ly way to transfer
binary data using RPC::Any. In XML-RPC, this translates to C<< <base64> >>.
In JSON-RPC it becomes a quoted string containing base64.
=item dateTime
A date and time. In XML-RPC, t
RPC::Any::Server::JSONRPC::HTTP;
use Moose;
use JSON::RPC::Common::Marshal::HTTP;
use HTTP::Response; # Needed because Marshal::HTTP doesn't load it.
extends 'RPC::Any::Server::JSONRPC';
with 'RPC::A
ny::Interface::HTTP';
has '+parser' => (isa => 'JSON::RPC::Common::Marshal::HTTP');
sub decode_input_to_object {
my ($self, $request) = @_;
if (uc($request->method) eq 'POST' and $request->c
eq '') {
$self->exception("ParseError",
"You did not supply any JSON to parse in the POST body.");
}
elsif (uc($request->method) eq 'GET' and !$request->uri->
erver::JSONRPC::CGI;
use Moose;
extends 'RPC::Any::Server::JSONRPC::HTTP';
with "RPC::Any::Interface::CGI";
__PACKAGE__->meta->make_immutable;
1;
__END__
=head1 NAME
RPC::Any::Server::JSONRPC::CG
=head1 SYNOPSIS
use RPC::Any::Server::JSONRPC::CGI;
# Create a server where calling Foo.bar will call My::Module->bar.
my $server = RPC::Any::Server::JSONRPC::CGI->new(
dispatch => { 'Foo' =
> 'My::Module' },
allow_get => 0,
);
# Read JSON from STDIN, headers from the environment. Print result,
# including HTTP headers for a CGI environment, to STDOUT.
print $server->handle_input(
package RPC::Any::Package::JSONRPC;
use strict;
use JSON;
use MIME::Base64;
BEGIN { *rpc_type = \&type };
sub type {
my ($self, $type, $value) = @_;
# This is the only type that does someth
g special with undef.
if ($type eq 'boolean') {
return $value ? JSON::true : JSON::false;
}
return JSON::null if !defined $value or $type eq 'nil';
my $retval = $value;
al = 0.0 + $value;
}
elsif ($type eq 'string') {
# Forces string context, so that JSON will make it a string.
$retval = "$value";
}
elsif ($type eq 'base64') {
PC and JSON-RPC.
=head1 DESCRIPTION
RPC::Any is a simple, unified interface to multiple RPC protocols.
Right now it supports L<XML-RPC|http://www.xmlrpc.com/> and all
three versions of L<JSON-RPC|ht
tp://groups.google.com/group/json-rpc/web>
(1.0, 1.1, and 2.0).
The goal of RPC::Any is to be simple to use, and to be highly extendable.
RPC::Any is designed to work properly in taint mode, and full
pp::Office::Contacts::Import::vCards::Util::vCards;
# Purpose:
# Read vCards in XML format.
use JSON::XS;
use XML::SAX::ParserFactory;
use Moose;
extends (qw/Moose::Object XML::SAX::Base/);
has
ny::Server::JSONRPC;
use Moose;
use Class::MOP;
use JSON::RPC::Common::Marshal::Text;
use RPC::XML qw(smart_encode);
extends 'RPC::Any::Server';
has parser => (is => 'rw', isa => 'JSON::RPC::Comm
on::Marshal::Text',
lazy_build => 1);
has _last_call => (is => 'rw', isa => 'JSON::RPC::Common::Procedure::Call',
clearer => '_clear_last_call');
has default_versi
=> 'rw', isa => 'Str', default => '2.0');
has '+package_base' => (default => 'RPC::Any::Package::JSONRPC');
before 'get_input' => sub {
my $self = shift;
$self->_clear_last_call();
};
sub d
ified at
L<http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php> (which
are valid for both JSON-RPC and XML-RPC).
What follows is a brief description of each type of error (which is
a subclass
package DBIx::CouchLike;
use 5.8.1;
use strict;
use warnings;
use Carp;
use JSON 2.0 ();
use UNIVERSAL::require;
use base qw/ Class::Accessor::Fast /;
use DBIx::CouchLike::Iterator;
use DBIx::CouchLi
able utf8 _json trace versioning /);
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->{utf8} = 1 unless defined $self->{utf8};
$self->{_json} = JSON->new;
$self->{_json}->utf8( $self->{utf8} );
_setup_downgrade() if !$self->{utf8} && !$RD;
}
$self->{utf8};
}
sub to_json {
my $self = shift;
my $json = $self->{_json}->encode(sh
? $couch->from_json($r->[2])
: $r->[2],
};
if ( $self->{query}->{include_docs} ) {
$res->{document} = $couch->from_json($r->[3]);
$res->{docum
it isn't provided.
=item format
=item formatter
C<format> is one of C<yaml>, C<storable> or C<json>, defaulting to C<yaml>.
C<formatter> is a code reference that is provided with a file handle an
roc::InvokeEditor>.
=item format
=item formatter
C<format> is one of C<yaml>, C<storable> or C<json>, defaulting to C<yaml>.
C<formatter> is a code reference which takes an entry as an argument. I
"ro",
default => "yaml",
cmd_aliases => "f",
documentation => "dump format ('yaml', 'json', 'storable', etc)"
);
has serializer => (
traits => [qw(NoGetopt EarlyBuild)],
isa => "
it isn't provided.
=item format
=item formatter
C<format> is one of C<yaml>, C<storable> or C<json>, defaulting to C<yaml>.
C<formatter> is a code reference which takes an entry as an argument. I
s class is designed primarily for tools that whish to populate the
C<provides> field of META.{yml,json} files so that the CPAN indexer will pay
attention to the existance of your classes, rather than
]+$!!; # delete trailing :<returntype>
$path_info =~ s!\.(html|xml|yaml|csv|pdf|perl|json)$!!; # delete trailing .<returntype>
if ($path_info =~ s!^/([A-Z][A-Za-z0-9]*)/!/!)
$returntype = $1;
}
elsif ($path_info =~ m!\.(html|xml|yaml|csv|pdf|perl|json)$!) {
$returntype = $1;
}
$self->{returntype} = $returntype;
}