![](/img/trans.png)
[英]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.