JSON::...:Client(3pm)
okay bestie, you're looking at the JSON::...:Client(3pm) page β yep, thatβs the manual slot, and it lives under User Contributed Perl Documentation. Itβs giving Perl JSON-RPC client realness, and weβre gonna go through every bit. π
π NAME π
JSON::RPC::Legacy::Client β Perl implementation of JSON-RPC client. Thatβs the whole name vibe, bestie.
β¨ SYNOPSIS β¨
okay so the quick-start looks like this, and yes, keep those variable names exactly as written:
use JSON::RPC::Legacy::Client;
my $client = new JSON::RPC::Legacy::Client;
my $url = 'http://www.example.com/jsonrpc/API';
my $callobj = {
method => 'sum',
params => [ 17, 25 ], # ex.) params => { a => 20, b => 10 } for JSON-RPC v1.1
};
my $res = $client->call($uri, $callobj);
if($res) {
if ($res->is_error) {
print "Error : ", $res->error_message;
}
else {
print $res->result;
}
}
else {
print $client->status_line;
}
# Easy access
$client->prepare($uri, ['sum', 'echo']);
print $client->sum(10, 23);
π¦ DESCRIPTION π¦
This is JSON-RPC Client. See <http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html>.
It gets a perl object and converts it to JSON request data.
It sends the request to a server.
It gets a response returned by the server.
It converts the JSON response data to the perl object.
π JSON::RPC::Legacy::Client π
πΈ METHODS πΈ
$client = JSON::RPC::Legacy::Client->newβ Creates a newJSON::RPC::Legacy::Clientobject. New client, who dis? π$response = $client->call($uri, $procedure_object)β Calls to$uriwith$procedure_object. The request method is usually"POST". If$urihas a query string, the method is"GET".
About the 'GET' method, see <http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html#GetProcedureCall>.
The return value is "JSON::RPC::Legacy::ReturnObject".
$client->prepare($uri, $arrayref_of_procedure)β Allows you to call methods in the contents of$arrayref_of_procedure. Then you can call the prepared methods with an array reference or a list.
The return value is the result part of JSON::RPC::Legacy::ReturnObject.
$client->prepare($uri, ['sum', 'echo']);
$res = $client->echo('foobar'); # $res is 'foobar'.
$res = $client->sum(10, 20); # sum up
$res = $client->sum( [10, 20] ); # same as above
If you call a method which is not prepared, it will croak.
Currently, you canβt call any method names that are the same as built-in methods. Noted, bestie. π
versionβ Sets the JSON-RPC protocol version.1.1by default.idβ Sets a request identifier. In JSON-RPC 1.1, it is optional.
If you set "version" to 1.0 and donβt set id, the module sets 'JSON::RPC::Legacy::Client' to it.
uaβ Setter/getter to theLWP::UserAgentobject.jsonβ Setter/getter to the JSON coder object. Default is JSON, likes this:
$self->json( JSON->new->allow_nonref->utf8 );
$json = $self->json;
This object serializes/deserializes JSON data. By default, returned JSON data assumes UTF-8 encoded.
status_lineβ Returns the status code; aftercallto a remote procedure, the status code is set.create_json_coderβ (Class method) Returns a JSON de/encoder innew. You can override it to use your favorite JSON de/encoder.
π JSON::RPC::Legacy::ReturnObject π
The call method or the methods set by prepared return this object. (The returned JSON data is decoded by the JSON coder object which was passed by the client object.)
π§ METHODS π§
is_successβ If the call is successful, returns a true value; otherwise returns a false value.is_errorβ If the call is not successful, returns a true value; otherwise returns a false value.error_messageβ If the response contains an error message, returns it.resultβ Returns the result part of a data structure returned by the called server.contentβ Returns the whole data structure returned by the called server.jsontextβ Returns the row JSON data.versionβ Returns the version of this response data.
π JSON::RPC::Legacy::ServiceObject π
π RESERVED PROCEDURE π
When a client calls a procedure (method) name 'system.foobar', JSON::RPC::Legacy::Server looks up MyApp::system::foobar.
<http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html#ProcedureCall>
<http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html#ServiceDescription>
There is JSON::RPC::Legacy::Server::system::describe for the default response of 'system.describe'.
π₯ SEE ALSO π₯
π 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.
okay thatβs the page, bestie π«Ά β source/version: perl v5.42.0; date: 2015-08-27; manual slot: JSON::...:Client(3pm). Bye! π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-JSON-RPC 1.06-bp160.1.11 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms