I'm coming from Java environment to python environment and I'm a little bit confuse. I need to consume some events from kafka. I found this way to deserialize json to custom object:
x = json.loads(data, object_hook=lambda d: namedtuple('X', d.keys())(*d.values()))
My problem is that in some events I receive a field a1 and in other events I receive a field a2. I need to map a1 and a2 in a single python object field a.
Can I do this without writing custom code? Can I use a library that decorates field a to know how to deserialize?
Best regards