Headless deserialization to dynamic object
would it be possible to create a feature to dynamically generate an object based on the schema
Something like this
dynamic obj = AvroConvert.DeserializeHeadless<ExpandoObject>(dataBytes, schemaStr);
Hello, Thank you for your idea. I will investigate the solution and come back to you. Regards, Adrian
Hello @alexander-miglis,
Sorry for the late answer. I am not sure if I get your question correctly, but the statement you have put is absolutely correct at the moment. As soon as ExpandoObject is supported #112 it will result with a dynamic object.
Regards, Adrian
I saw you added this feature and I appreciate that you consider doing it. It would really help me to dynamically read objects from Kafka and re-serialize them as json for example.
Hello @alexander-miglis
The new feature is ready. It's available from v 3.4.0 I've found another way of doing so. It's simply:
dynamic deserializedObject = AvroConvert.Deserialize<dynamic>(byte[] avroObject);
Please let me know if it solves your case. For Avro to Json conversion, you can simply use AvroConvert.Avro2Json extension.
Best, Adrian
Edit: Uh, it does not work with headless Avro files yet
In my use case I get the schema from a schema registry and then read out the message from Kafka headless. So unfortunately this solution does not work for me yet... I would require the headless version of this feature.
The idea is that I would be able to use the dynamic object to serialize it to other formats, like json, without having to implement a full object that matches the schema.