C# 如何将对象序列化/反序列化到c中的avro#
我曾使用json.net将pojo类序列化/反序列化为json,然后将其发送到rabbitmq。现在我想使用apache avro格式的二进制数据执行同样的操作。如何在c#中序列化/反序列化对象C# 如何将对象序列化/反序列化到c中的avro#,c#,avro,avro-tools,C#,Avro,Avro Tools,我曾使用json.net将pojo类序列化/反序列化为json,然后将其发送到rabbitmq。现在我想使用apache avro格式的二进制数据执行同样的操作。如何在c#中序列化/反序列化对象 下面的代码适用于您的问题 byte[] avroFileContent = File.ReadAllBytes(fileName); Dictionary<string, object> result = AvroConvert.Deserialize(avroFileContent);
下面的代码适用于您的问题
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);
byte[]avroFileContent=File.ReadAllBytes(文件名);
Dictionary result=AvroConvert.Deserialize(avroFileContent);
//或者如果你知道数据的模型
person(您的类型)result=AvroConvert.Deserialize(avroFileContent);
类似的问题很多。您是否尝试过在SO中搜索c#avro
,或在NuGet中搜索avro
?NuGet中至少有36个名为Avro
的包。我在这个库中遇到了一些问题,正在寻找正式或可靠的解决方案。Apache.Avro是正式的Apache NuGet包:。在官方ApacheAvroGithub项目的C#自述文件中也有这样的标识:。不幸的是,目前C#library没有那么好的操作文档。如果您熟悉Java库,您可能很快就能学会它。
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);