JSON-RPC
   HOME

TheInfoList



OR:

JSON-RPC is a
remote procedure call In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure ( subroutine) to execute in a different address space (commonly on another computer on a shared network), which is coded as if it were a normal ...
protocol Protocol may refer to: Sociology and politics * Protocol (politics), a formal agreement between nation states * Protocol (diplomacy), the etiquette of diplomacy and affairs of state * Etiquette, a code of personal behavior Science and technology ...
encoded in
JSON JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other se ...
. It is similar to the
XML-RPC XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism.Simon St. Laurent, Joe Johnston, Edd Dumbill. (June 2001) ''Programming Web Services with XML-RPC.'' O'Reilly. First Edition ...
protocol, defining only a few data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered asynchronously.


History


Usage

JSON-RPC works by sending a request to a server implementing this protocol. The client in that case is typically software intending to call a single method of a remote system. Multiple input parameters can be passed to the remote method as an array or object, whereas the method itself can return multiple output data as well. (This depends on the implemented version.) All transfer types are single objects, serialized using JSON. A request is a call to a specific method provided by a remote system. It can contain three members: * method - A String with the name of the method to be invoked. Method names that begin with "rpc." are reserved for rpc-internal methods. * params - An Object or Array of values to be passed as parameters to the defined method. This member may be omitted. * id - A string or non-fractional number used to match the response with the request that it is replying to. This member may be omitted if no response should be returned. The receiver of the request must reply with a valid response to all received requests. A response can contain the members mentioned below. * result - The data returned by the invoked method. If an error occurred while invoking the method, this member must not exist. * error - An error object if there was an error invoking the method, otherwise this member must not exist. The object must contain members ''code'' (integer) and ''message'' (string). An optional ''data'' member can contain further server-specific data. There are pre-defined error codes which follow those defined for XML-RPC. * id - The id of the request it is responding to. Since there are situations where no response is needed or even desired, notifications were introduced. A notification is similar to a request except for the id, which is not needed because no response will be returned. In this case the id property should be omitted (Version 2.0) or be null (Version 1.0).


Examples

In these examples, --> denotes data sent to a service (''request''), while <-- denotes data coming from a service. Although <-- is often called a ''response'' in client–server computing, depending on the JSON-RPC version it does not necessarily imply an ''answer'' to a request''.''


Version 2.0

Request and response: --> <-- Notification (no response): -->


Version 1.1 (Working Draft)

Request and response: --> <--


Version 1.0

Request and response: --> <--


See also

*
Remote procedure call In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure ( subroutine) to execute in a different address space (commonly on another computer on a shared network), which is coded as if it were a normal ...
(RPC) *
XML-RPC XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism.Simon St. Laurent, Joe Johnston, Edd Dumbill. (June 2001) ''Programming Web Services with XML-RPC.'' O'Reilly. First Edition ...
* gRPC * SOAPjr - a hybrid of SOAP and JSON-RPC * JSON-WSP - a JSON-RPC inspired protocol with a service description specification.


References


External links

*
JSON-RPC Google Group
discussing topics of and around the protocol
JSON-RPC specifications, MNlinks etc.


description for JSON-RPC-2
OpenRPC Specification
Service description format for JSON-RPC. (open-api, but for json rpc)
JSend
- a similar specification which defines only format of response {{DEFAULTSORT:Json-Rpc JSON Web services Remote procedure call