def __repr__(self):
    return str(self.__dict__)

def to_dict(self):
    return dict(item1=self.item1)

@classmethod
def from_dict(cls, dct):
    return cls(**dct)
s = json.dumps(A(1), default=registry.default)
a = json.loads(s, object_hook=registry.object_hook)
How to make simplejson serializable class