JSON 还是 SOAP (XML)? [英] JSON or SOAP (XML)?

查看:29
本文介绍了JSON 还是 SOAP (XML)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为公司开发一个新的应用程序.应用程序必须与 iPhone 交换数据.

I'm developing a new application for the company. The application have to exchange data from and to iPhone.

公司服务器端使用.NET框架.

Company server side uses .NET framework.

例如:特定 CustomerNumber 的类Customer"(姓名、地址等)应首先从服务器下载到 iphone,存储在本地,然后上传回应用更改(并使其可供其他人使用).并发应该不是问题(至少在这个时候...)

For example: the class "Customer" (Name, Address etc..) for a specific CustomerNumber should be first downloaded from server to iphone, stored locally and then uploaded back to apply changes (and make them available to other people). Concurrency should not be a problem (at least at this time...)

无论如何,我必须同时开发服务器端(网络服务或其他)和 iPhone 应用程序.

In any case I have to develop both the server side (webservice or whatever) and the iPhone app.

我可以自由确定最好的方法(这是应用程序第一",因此它将成为未来的标准").

I'm free to identify the best way to do that (this is the application "number ONE" so it will become the "standard" for the future).

那么,你对我有什么建议?

So, what do you suggest me ?

使用 SOAP 网络服务(XML 解析等)或用户 JSON ?(好像更轻了……)我是否清楚如何使用 SOAP上传"数据(编码 xmlsoap 信封很长......我会避免)但我如何使用 JSON 做同样的事情?

Use SOAP web services (XML parsing etc..) or user JSON ? (it seems lighter...) Is it clear to me how to "upload" data using SOAP (very long to code the xml soap envelope ... I would avoid) but how can I do the same using JSON ?

应用程序需要使用日期值(例如:last_visit_date 等),那么 Json 中的日期呢?

The application needs to use date values (for example: last_visit_date etc..) what about date in Json ?

推荐答案

JSON 比 XML 有几个优点.它更小,更不臃肿,因此您将通过网络传递更少的数据 - 这在移动设备的情况下会产生相当大的差异.

JSON has several advantages over XML. Its a lot smaller and less bloated, so you will be passing much less data over the network - which in the case of a mobile device will make a considerable difference.

在javascript代码中也更容易使用,因为您可以直接将数据包直接传递到javascript数组中,而无需任何解析、提取和转换,因此它对CPU的占用也少得多.

Its also easier to use in javascript code as you can simply pass the data packet directly into a javascript array without any parsing, extracting and converting, so it is much less CPU intensive too.

要使用它进行编码,您需要一个 JSON 库,而不是 XML 库.日期的处理方式与 XML 相同 - 将它们编码为标准,然后让库识别它们.(例如,这里有一个库,其中包含一个带有日期的示例)

To code with it, instead of an XML library, you will want a JSON library. Dates are handled as you would with XML - encode them to a standard, then let the library recognise them. (eg here's a library with a sample with dates in it)

这是一个入门.

这篇关于JSON 还是 SOAP (XML)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆