pavlov99 / json-rpc

🔁 JSON-RPC 1/2 transport implementation. Supports python 2/3 and pypy.
http://json-rpc.readthedocs.org
MIT License
464 stars 101 forks source link

Allow to change the serialization and deserialization methods used by the library #94

Closed 0xFelix closed 4 years ago

0xFelix commented 6 years ago

Description of the Change

Subclass JSONSerializable from JSONRPC20BatchRequest and JSONRPC20BatchResponse to allow usage of JSONSerializable's methods serialize and deserialize.

Decouple request validation from JSONRPCResponseManager's handle method and introduce a static method inside JSONRPCResponseManager named deserialize (analogous to JSONSerializable).

Benefits

These changes allow to change the serialization and deserialization methods used by the library without overwriting its logic. (e.g. use cbor2.loads / cbor2.dumps instead of json.loads / json.dumps)