Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将对象序列化/反序列化到c中的avro#_C#_Avro_Avro Tools - Fatal编程技术网

C# 如何将对象序列化/反序列化到c中的avro#

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);

我曾使用json.net将pojo类序列化/反序列化为json,然后将其发送到rabbitmq。现在我想使用apache avro格式的二进制数据执行同样的操作。如何在c#中序列化/反序列化对象


下面的代码适用于您的问题

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);