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
- notification
- No id, no response
- batch
- Array of requests
{"jsonrpc":"2.0",...} fire and forget 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
- impl errors
- -32000 to -32099
- LSP
- Language Server Protocol
standard set reserved range uses JSON-RPC