duron.codec
module
Codec
Bases: Protocol
Protocol for encoding/decoding Python objects to/from JSON-serializable values.
Implement this protocol to provide custom serialization for types not supported by the default codec (e.g., dataclasses, Pydantic models, custom objects).
decode_json
decode_json(encoded, expected_type)
encode_json
encode_json(result)
Convert a Python object to a JSON-serializable value for persistence.
Parameters:
-
result
(object
) –The object to encode (e.g., operation result or argument)
Returns:
-
JSONValue
–A JSON-serializable value (None, bool, int, float, str, list, or dict)
Raises:
-
TypeError
–If the object cannot be serialized