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

查看:111
本文介绍了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...)

无论如何,我都必须同时开发服务器端(Web服务或其他)和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 Web服务(XML解析等)还是用户JSON? (看起来更轻...) 我是否很清楚如何使用SOAP上载"数据(很长一段时间才能编写xml soap信封代码……我会避免),但是如何使用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.

要使用它进行编码,而不是XML库,您将需要JSON库.与使用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天全站免登陆