I would like to use jsonpickle to serialise my complex object with unpicklable=False. However, the unpicklable only applies to the first object, rather than the nested one.
I have the following object to serialise
T = TypeVar('T')
class Result(Generic[T]):
def __init__(self, is_success: bool, payload: T = None, error: Error = None):
self.isSuccess: bool = is_success
if is_success:
self.successPayload: T = payload
else:
self.failedPayload: Error = error
And the nested object T
is
class Coordinate:
def __init__(self, coordinate):
self.coordinate= coordinate
The result of jsonpickle.encode(result, unpicklable=False)
is
{"isSuccess": true, "successPayload": {"coordinate": {"dtype": "float64", "values": [-0.4022799336814849, 0.8902557877735706, -0.17517361570654688]}}, "__orig_class__": {"_inst": true, "_special": false, "_name": null, "__origin__": {"py/type": "toolbox.model.result.Result"}, "__args__": [{"py/type": "Coordinate"}], "__parameters__": [], "__slots__": null, "__module__": "toolbox.model.result"}
Can anyone please give some advice how to remove fields, such as __orig_class__
, from the nested object?
Thank you