一般来说,重要的问题是哪个客户端将接收序列化的对象——浏览器/JavaScript引擎,如(node js)、Java客户端、未知/多个客户端.
JSON -
JSON syntax is basically JavaScript and therefore any component with a JS engine will handle its parsing very well - even complicated data-structures will be converted to "living" objects efficiently. JSON parsers exist for practically any language and it is easy to use even when not using a JS engine, (Take Google Gson for example that is able to convert JSON into corresponding objects with ease) which makes is a good candidate for cross-language communication - for example in a messaging architecture.
XML-
共享JSON的许多好处-跨语言、轻量级等.例如,Adobe Flex处理XML非常好,甚至比JSON更好.对于json来说,这绝对是一个合适的替身.我个人更喜欢JSON,因为它类似于JS的语法,但是XML也很好.
Java序列化-
应仅考虑用于Java到Java通信.重要的一点是,class definitions应该在发送端和接收端,通常通过传递整个对象不会获得太多好处.我不排除RMI作为通信协议,它确实简化了开发.然而,由此产生的应用程序组件将是硬耦合的,这将使其很难替换.
One more notes - Serialization in general has its overhead. However when the communication is performed over a network the bottleneck is often the network rather than the serialization/deserialization itself.