JSONRPC::Transport::HTTP
#-------------------------- # In your application class package MyApp; sub own_method { # called by clients my ($server, @params) = @_; # $server is JSONRPC object. ... # return a scalar value or a hashref or an arryaref. } #-------------------------- # In your main cgi script. use JSONRPC::Transport::HTTP; use MyApp; # a la XMLRPC::Lite JSONRPC::Transport::HTTP::CGI->dispatch_to('MyApp')->handle();
This module is JSONRPC subclass. Most ideas were borrowed from XMLRPC::Lite. Currently JSONRPC provides only CGI server function.
JSONRPC
When the module returns response, its charset is UTF-8 by default. You can change it via passing a key/value pair into handle().
my %charset = (charset => 'EUC-JP'); JSONRPC::Transport::HTTP::CGI->dispatch_to('MyApp')->handle(%charset);
If you want to use any other query object instead of CGI for JSONRPC::Transport::HTTP::CGI, you can pass query option and paramName.
CGI
query
paramName
my %opt = ( query => $session, # CGI::Session object paramName => 'json', ); JSONRPC::Transport::HTTP::CGI->dispatch_to('MyApp')->handle(%opt);
JSONRPC::Transport::HTTP::CGI requires CGI.pm which version is more than 2.9.2. (the core module in Perl 5.8.1.)
JSONRPC JSON XMLRPC::Lite http://json-rpc.org/
Makamaka Hannyaharamitu, <makamaka[at]cpan.org>
Copyright 2005 by Makamaka Hannyaharamitu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install JSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON
CPAN shell
perl -MCPAN -e shell install JSON
For more information on module installation, please visit the detailed CPAN module installation guide.