使用ProtoBuf-Net,如何对多维数组进行(反)序列化?

发布于 2024-09-30 11:34:27 字数 50 浏览 0 评论 0原文

由于 ProtoBuf-Net 不支持序列化/反序列化多维数组,我将如何管理我的数组?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2024-10-07 11:34:27

这本质上是底层 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.

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文