Content deleted Content added
m →Usage: Remove the incorrect assertion about result formatting |
gr. |
||
(11 intermediate revisions by 4 users not shown) | |||
Line 1:
{{Short description|
'''JSON-RPC''' ('''JavaScript Object Notation-Remote Procedure Call''') is a [[
The JSON-RPC protocol is transport-independent and can be carried over many different data transport protocols, including [[file descriptor]] I/O, [[HTTP]] and [[TCP]]. It does not directly provide any support for authentication or authorization.
== History ==
Line 42 ⟶ 44:
All transfer types are single objects, serialized using JSON.<ref name="json-rpc1">{{Cite web |url=http://json-rpc.org/wiki/specification |title=specification - JSON-RPC - Trac<!-- Bot generated title --> |access-date=2008-05-14 |archive-url=https://web.archive.org/web/20080517011921/http://json-rpc.org/wiki/specification |archive-date=2008-05-17 |url-status=dead }}</ref> A request is a call to a specific method provided by a remote system. It can contain three members:
* <code>method</code> - A
* <code>params</code> - An
* <code>id</code> - A string or non-fractional number used to match the response with the request that it is replying to.<ref>{{cite web|url=https://www.jsonrpc.org/specification|title=JSON-RPC 2.0 Specification|quote=id: An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null and Numbers SHOULD NOT contain fractional parts}}</ref> This member may be omitted if no response should be returned.<ref>{{cite web|url=https://www.jsonrpc.org/specification|title=JSON-RPC 2.0 Specification|quote=A Notification is a Request object without an "id" member. A Request object that is a Notification signifies the Client's lack of interest in the corresponding Response object, and as such no Response object needs to be returned to the client. The Server MUST NOT reply to a Notification, including those that are within a batch request. Notifications are not confirmable by definition, since they do not have a Response object to be returned. As such, the Client would not be aware of any errors (like e.g. "Invalid params", "Internal error").}}</ref>
The receiver of the request must reply with a valid response to all received requests. A response can contain the members mentioned below.
Line 61 ⟶ 63:
=== Version 2.0 ===
Request and response:
<syntaxhighlight lang="
--> {"jsonrpc": "2.0", "method": "subtract", "params": {"minuend": 42, "subtrahend": 23}, "id": 3}
<-- {"jsonrpc": "2.0", "result": 19, "id": 3}
</syntaxhighlight>
Notification (no response):
<syntaxhighlight lang="
--> {"jsonrpc": "2.0", "method": "update", "params": [1,2,3,4,5]}
</syntaxhighlight>
Line 72 ⟶ 74:
=== Version 1.1 (Working Draft) ===
Request and response:
<syntaxhighlight lang="
--> {"version": "1.1", "method": "confirmFruitPurchase", "params": [["apple", "orange", "mangoes"], 1.123], "id": "194521489"}
<-- {"version": "1.1", "result": "done", "error": null, "id": "194521489"}
Line 79 ⟶ 81:
=== Version 1.0 ===
Request and response:
<syntaxhighlight lang="
--> {"method": "echo", "params": ["Hello JSON-RPC"], "id": 1}
<-- {"result": "Hello JSON-RPC", "error": null, "id": 1}
Line 85 ⟶ 87:
== See also ==
* [[gRPC]] - cross-platform binary RPC protocol
* [[SOAP]] - a messaging protocol
▲* [[JSON-WSP]] - a JSON-RPC inspired protocol with a service description specification.
== References ==
Line 101:
* [https://open-rpc.org OpenRPC Specification] Service description format for JSON-RPC. (open-api, but for json rpc)
* [https://github.com/omniti-labs/jsend JSend] - a similar specification which defines only format of response
{{DEFAULTSORT:Json-Rpc}}
|