使用protobuf网,如何(德)序列化一个多维数组? [英] Using ProtoBuf-Net, how to (de)serialize a multi-dimensional array?

查看:1972
本文介绍了使用protobuf网,如何(德)序列化一个多维数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于protobuf网不支持串行化/反序列化的多维数组,我将如何去管理我的阵列?

Since ProtoBuf-Net does not support serializing/deserializing multi-dimensional arrays, how would I go about managing my arrays?

推荐答案

这是本质上是底层的protobuf传输格式的限制;它只支持单维数组。

This is essentially a limitation of the underlying protobuf wire format; it only supports single-dimension arrays.

两个选项飞跃头脑;首先,发送它作为一个线性阵列,并分别发送的尺寸。

Two options leap to mind; firstly, send it as a linear array, and send the dimensions separately.

您也可以重新present它作为对象的列表,每个的阵列 - 基本上交错数组,但与中间步骤

You could also represent it as a list of objects that each has an array - essentially a jagged array, but with an intermediate step.

在这两个,第一是既简单,更有效。

Of the two, the first is both simpler and more efficient.

无论哪种方式,如果您要发送类似intergers,你应该看看压缩编码(可通过选项属性) - 这可以进一步减少有效载荷阵列等

Either way, if you are sending something like intergers, you should look at "packed" encoding (available via the options property) - this can further reduce the payload for arrays etc.

这篇关于使用protobuf网,如何(德)序列化一个多维数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆