We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
您显然不是在这里寻找序列化。
序列化是保存一个对象,然后从字节流中重新创建它。想想视频游戏保存或网络服务器的会话上下文。
这里你需要的是消息传递。 Google 的 FlatBuffers 对此非常有用。指定一条消息,其中包含每个可选字段,收到消息后,使用确实存在的字段更新您的对象,并保持其他字段不变。
FlatBuffers 的伟大之处在于,除了零成本解析步骤之外,它还可以很好地处理向前和向后兼容性,以及文本和二进制编码(文本非常适合调试,二进制更适合纯性能)。
如果您将消息保存在某个地方并且想要拼凑一个 html gui 来检查它,您甚至可以使用另一种语言(例如 python 或 ruby)来解码消息!
You're clearly not looking for serialization here.
Serialization is about saving an object and then recreating it from the stream of bytes. Think video games saves or the session context for a webserver.
Here what you need is messaging. Google's FlatBuffers is nice for that. Specify a message that will contain every single field as optional, upon reception of the message, update your object with the fields that do exist and leave the others untouched.
The great thing with FlatBuffers is that it handles forward and backward compatibility nicely, as well as text and binary encoding (text being great for debugging and binary being better for pure performance), on top of a zero-cost parsing step.
And you can even decode the messages with another language (say python or ruby) if you save them somewhere and want to throw together a html gui to inspect it!
虽然我对它们不熟悉,但您也可以查看 Google 的 Protocol Buffers
。
Although I'm not familiar with them, you could also check out Google's Protocol Buffers
.