英文:
What is the best way to serialize/deserialize data and send over TCP
问题
基本上,我有一个Go服务器,它解析一些XML文件并创建一个包含数据的结构,我想将其通过TCP发送到一个IOS应用程序。
目前,我尝试使用Protocol Buffers,但在IOS端遇到了问题。所以根据你的经验,这是我传输数据的最佳方式吗?还有其他建议吗?
我首先要考虑的是速度。
英文:
Basically I have a Go server which parses some XML file and creates a structure with the data which I want to send over TCP to an IOS app.
At the moment I tried to use Protocol Buffers, but I am having problems with this on the IOS side. So from your experience is this the best way I should transmit my data ? Any other suggestions ?
The first thing I am looking for it's speed.
答案1
得分: 3
没有最好的方法。有很多跨平台序列化格式可供选择。只需选择您最熟悉且适合您需求的即可。
一个明显的选择是json(易读且在所有平台上都有很好的支持)。
如果您更注重速度,可以看看msgpack:
- http://msgpack.org/
- https://github.com/msgpack/msgpack-go
- https://github.com/msgpack/msgpack-c
- https://github.com/msgpack/msgpack-objectivec
英文:
There is no best way. There are plenty of cross-platform serialization formats out there. Just pick the one you are the most comfortable with, and which suits your needs.
An obvious choice is json (human readable and well supported on all platforms).
If you favor speed, then have a look at msgpack:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论