I have a JSON that user can modify outside my code. In that, I have full class name like:
models.InputLoader.InputLoader
When I load it in code, I get this a string representation.
I want to call static method unseralize
to which I pass another datum from JSON via dictionary.
InputLoader:
@staticmethod
def unserialize(d: Dict) -> InputLoader:
return InputLoader(d["x"])
def __init__(self, x):
self.x = x
In JSON:
{
"class": "models.InputLoader.InputLoader"
"x": 45
}
How can I do this?