[英]How to serialize/deserialize from ksql avro format to c# using confluent platform
[英]How to serialize/deserialize an object to avro in c#
I was using json.net to serialize/deserialize a pojo class to json and then send it to rabbitmq.Now I want to do the same using binary data in apache avro format.How is it possible to serialize/deserialize an object in c#?
public class person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public byte[] toAvro()
{
}
public void fromAvro(byte[] input)
{
}
}
下面的代码很适合您的问题。
byte[] avroFileContent = File.ReadAllBytes(fileName);
Dictionary<string, object> result = AvroConvert.Deserialize(avroFileContent);
//or if u know the model of the data
person(Your Type) result = AvroConvert.Deserialize<MyModel>(avroFileContent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.