I have created a dict that contains a string key and some class as a value. Now I want to use json to serialize it and de-serialize it.
class A:
def __init__(self, val):
self.val = val
class B(A):
def __init__(self, val, additional_val):
super(B, self).__init__(val)
self.additional_val= additional_val
class C(B):
def __init__(self, val, additional_val, enabled):
super(C, self).__init__(val, additional_val)
self.enabled = enabled
my_dict = {'0': A(0), '1': B(5, 6), '2': C(7,8,True)}
now I want to serialize it. I found that the easiest way to serialize it with jsons (using python 3.6). But how can I de-serialize it back to the original objects ? all the examples that I found was for very simple objects (str, dict, list).