从Node.js Server Env中从C#客户端处理序列化对象的最佳方法
从C#客户端代码发送到Node.js Server环境的正确/主流方法是什么?
现在,我正在使用binaryWriter
(客户端)和streambuf
npm-package(服务器端)使用标准C#序列化。
但是我很确定,有一种更直接的/本机/主流/有效的方法。
我要做什么?
谢谢您的建议!
What's the correct/mainstream way to handle byte arrays
sent from C# client code to Node.js server environment?
Now I'm using standard C# serialization through BinaryWriter
(client-side) and streambuf
npm-package (server-side).
But I'm pretty sure that there is a more straightforward/native/mainstream/efficient way to do it.
What I have to do?
Thank you for your advices!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将对象转换为序列化表示形式的主流方法是使用序列化框架。如果您正在使用node.js,我会假设 json 最合适的。我不熟悉node.js,但我的理解是它本地处理JSON。另请参见 newtonsoft json for另一个非常受欢迎的库。
如果您需要更多更紧凑的序列化格式,则可以看一下 protobobuf 序列化为二进制格式。看来有Protobuf软件包可用于Node.js,但同样,我对JavaScript不熟悉。
使用现有的序列化格式倾向于使在不同系统之间共享对象变得更容易,因为通常有库可用于最常见的平台的大多数流行格式。通常,它也使兼容性更容易,因为许多格式可以为可选字段之类的东西提供一些灵活性。因此,如果您发现需要添加更多数据,则通常可以这样做,以确保它不会破坏现有用户。
The mainstream way to convert an object to a serialized representation would be to use a serialization framework. If you are using node.js I would assume json would be most appropriate. I'm not familiar with Node.js, but my understanding is that it handles json natively. See also newtonsoft json for another very popular library.
If you need more a more compact serialization format you might take a look at protobuf since that serializes to a binary format. It looks like there are protobuf packages available for Node.js, but again, I have no familiarity with javascript.
Using an existing serialization format tend to make it easier to share objects between different systems since there are usually libraries available for most popular formats for the most common platforms. It usually also makes compatibility easier since many formats allow some flexibility for things like optional fields. So if you find that you need to add some more data you can often do so in the confidence that it will not break existing users.