When trying to serialize to JSON an object generated from an schema with a bytes type it fails with following error:
Traceback (most recent call last):
File "O:\ws\mdp\avro-to-python\mytest.py", line 13, in <module>
print(f"Hello CDM. This is my first entity: {myEvent.serialize()}")
File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\mdh_model_common\com\kapschtraffic\mdp\mdh\model\common\events\BaseEvent.py", line 259, in serialize
return json.dumps(self, default=default_json_serialize)
File "C:\Users\miguelez\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 238, in dumps
**kw).encode(obj)
File "C:\Users\miguelez\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Users\miguelez\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\mdh_model_common\helpers.py", line 11, in default_json_serialize
return obj.__dict__
AttributeError: 'bytes' object has no attribute '__dict__'. Did you mean: '__dir__'?
Process finished with exit code 1
When trying to serialize to JSON an object generated from an schema with a
bytes
type it fails with following error: