Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

json::rpc(3pm) [debian man page]

JSON::RPC(3pm)						User Contributed Perl Documentation					    JSON::RPC(3pm)

NAME
JSON::RPC - Perl implementation of JSON-RPC 1.1 protocol DESCRIPTION
JSON-RPC is a stateless and light-weight remote procedure call (RPC) protocol for inter-networking applications over HTTP. It uses JSON as the data format for of all facets of a remote procedure call, including all application data carried in parameters. quoted from <http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html>. This module was in JSON package on CPAN before. Now its interfaces was completely changed. The old modules - JSONRPC::Transport::HTTP and Apache::JSONRPC are deprecated. Please try to use JSON::RPC::Server and JSON::RPC::Client which support both JSON-RPC protocol version 1.1 and 1.0. EXAMPLES
CGI version. #-------------------------- # In your application class package MyApp; use base qw(JSON::RPC::Procedure); # Perl 5.6 or more than sub echo : Public { # new version style. called by clients # first argument is JSON::RPC::Server object. return $_[1]; } sub sum : Public(a:num, b:num) { # sets value into object member a, b. my ($s, $obj) = @_; # return a scalar value or a hashref or an arryaref. return $obj->{a} + $obj->{b}; } sub a_private_method : Private { # ... can't be called by client } sub sum_old_style { # old version style. taken as Public my ($s, @arg) = @_; return $arg[0] + $arg[1]; } #-------------------------- # In your triger script. use JSON::RPC::Server::CGI; use MyApp; # simple JSON::RPC::Server::CGI->dispatch('MyApp')->handle(); # or JSON::RPC::Server::CGI->dispatch([qw/MyApp FooBar/])->handle(); # or INFO_PATH version JSON::RPC::Server::CGI->dispatch({'/Test' => 'MyApp'})->handle(); #-------------------------- # Client use JSON::RPC::Client; my $client = new JSON::RPC::Client; my $uri = 'http://www.example.com/jsonrpc/Test'; my $obj = { method => 'sum', # or 'MyApp.sum' params => [10, 20], }; my $res = $client->call( $uri, $obj ) if($res){ if ($res->is_error) { print "Error : ", $res->error_message; } else { print $res->result; } } else { print $client->status_line; } # or $client->prepare($uri, ['sum', 'echo']); print $client->sum(10, 23); See to JSON::RPC::Server::CGI, JSON::RPC::Server::Daemon, JSON::RPC::Server::Apache JSON::RPC::Client and JSON::RPC::Procedure. ABOUT NEW VERSION
supports JSON-RPC protocol v1.1 TODO
Document Examples More Tests AUTHOR
Makamaka Hannyaharamitu, <makamaka[at]cpan.org> COPYRIGHT AND LICENSE
Copyright 2007-2008 by Makamaka Hannyaharamitu This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2008-09-01 JSON::RPC(3pm)

Check Out this Related Man Page

Mojo::JSON(3pm) 					User Contributed Perl Documentation					   Mojo::JSON(3pm)

NAME
Mojo::JSON - Minimalistic JSON SYNOPSIS
use Mojo::JSON; my $json = Mojo::JSON->new; my $bytes = $json->encode({foo => [1, 2], bar => 'hello!'}); my $hash = $json->decode($bytes); DESCRIPTION
Mojo::JSON is a minimalistic and relaxed implementation of RFC 4627. While it is possibly the fastest pure-Perl JSON parser available, you should not use it for validation. It supports normal Perl data types like "Scalar", "Array" reference, "Hash" reference and will try to call the "TO_JSON" method on blessed references, or stringify them if it doesn't exist. [1, -2, 3] -> [1, -2, 3] {"foo": "bar"} -> {foo => 'bar'} Literal names will be translated to and from Mojo::JSON constants or a similar native Perl value. true -> Mojo::JSON->true false -> Mojo::JSON->false null -> undef Decoding UTF-16 (LE/BE) and UTF-32 (LE/BE) will be handled transparently, encoding will only generate UTF-8. The two unicode whitespace characters "u2028" and "u2029" will always be escaped to make JSONP easier. ATTRIBUTES
Mojo::JSON implements the following attributes. "error" my $err = $json->error; $json = $json->error('Oops!'); Parser errors. METHODS
Mojo::JSON inherits all methods from Mojo::Base and implements the following new ones. "decode" my $array = $json->decode($bytes); my $hash = $json->decode($bytes); Decode JSON. "encode" my $bytes = $json->encode({foo => 'bar'}); Encode Perl structure. "false" my $false = Mojo::JSON->false; my $false = $json->false; False value, used because Perl has no native equivalent. "true" my $true = Mojo::JSON->true; my $true = $json->true; True value, used because Perl has no native equivalent. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::JSON(3pm)
Man Page