简体   繁体   English

在不同平台之间共享对象

[英]Sharing objects between different platforms

I wrote the server and all the Windows clients in VB.NET, and I'm using XML serialization to share objects between them. 我在VB.NET中编写了服务器和所有Windows客户端,并且正在使用XML序列化在它们之间共享对象。

We need to have Android and iOS devices connect to the server, but I'm not able to get XML serialization to work the way it does in .NET, so I looked at other protocols that all three implement. 我们需要将Android和iOS设备连接到服务器,但是我无法使XML序列化按.NET中的方式工作,因此我研究了这三个协议都实现的其他协议。 I was able to get Android to convert an object to JSON to send via socket stream, so if I can get iOS to do the same thing, I'll probably end up going that route and re-implement JSON instead of XML. 我能够让Android将对象转换为JSON,以通过套接字流发送,因此,如果我可以让iOS做同样的事情,我可能最终会走这条路线并重新实现JSON而不是XML。 Microsoft just makes it so easy to serialize/deserialize objects to XML. Microsoft只是很容易将对象序列化/反序列化为XML。

Are there any better ways besides XML or JSON to transmit objects between different platforms when using a socket? 使用套接字时,除了XML或JSON之外,还有其他更好的方法可以在不同平台之间传输对象吗?

If you want to implement JSON in iOS, you can have a look at this tutorial : 如果要在iOS中实现JSON,可以看一下本教程:

Ray Wenderlich's Working with JSON in iOS 5 Tutorial . Ray Wenderlich的《 在iOS 5教程中使用JSON》

From the first line of the tutorial : 从教程的第一行开始:

iOS 5 has some new built-in APIs to make it really easy to read and write JSON. iOS 5具有一些新的内置API,可以非常轻松地读取和写入JSON。

So if you're targeting iOS 5+ devices (probably the most reasonable choice today), you're good to go with JSON (I used it in a project, really easy to get working quick). 因此,如果您的目标是iOS 5+设备(今天可能是最合理的选择),那么您最好使用JSON(我在项目中使用过它,真的很容易快速上手)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM