Generate JSON-RPC requests and parse responses in Python.
pip install jsonrpcclient
Generate a request:
from jsonrpcclient import request, parse
req = request("ping")
# => {'jsonrpc': '2.0', 'method': 'ping', 'id': 1}
Parse a response:
parsed = parse({"jsonrpc": "2.0", "result": "pong", "id": 1})
# => Ok(result='pong', id=1)
For strings, use request_json
and parse_json
.
Watch a video on how to use it
Full documentation is at jsonrpcclient.com.
See also: jsonrpcserver