跳到主要内容
uencoder

JSON-RPC 2.0 Specification

Reference 为 JSON-RPC 2.0: stateless, lightweight remote 过程调用协议 using JSON.

Message Format

JSON-RPC 2.0 defines Request, Response, and Notification objects as JSON. Requests contain method, params (array or object), and id. Responses contain result or error with the matching id. Notifications omit the id and receive no response. Batch requests send an array of requests processed in order. The protocol is transport-agnostic (HTTP, WebSocket, stdio). Version 2.0 is specified in a single document.

request
method + params + id
{"jsonrpc":"2.0",...}
notification
No id, no response
fire and forget
batch
Array of requests
processed in order

Error Handling

Error objects contain code (integer), message (string), and optional data. Pre-defined codes: -32700 (parse error), -32600 (invalid request), -32601 (method not found), -32602 (invalid params), -32603 (internal error). Codes -32000 to -32099 are reserved for implementation errors. The protocol does not define authentication or transport details. JSON-RPC is used in Ethereum nodes, Language Server Protocol, and custom APIs.

error codes
Pre-defined -32xxx
standard set
impl errors
-32000 to -32099
reserved range
LSP
Language Server Protocol
uses JSON-RPC

相关工具

参考链接