当你使用XML在JSON阿贾克斯? [英] When would you use XML over JSON for Ajax?

查看:133
本文介绍了当你使用XML在JSON阿贾克斯?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,许多程序员和包括我,都采取了在X了AJAX,并且在默认情况下使用JSON作为协议的格式。不过我试图想一些地方,XML会更合适作为协议的格式,不包括SOAP(SOAP,因为在理论上可以使用JSON完成反正)。

Recently, many programmers and that includes me, have taken the X out of AJAX, and by default use JSON as the protocol format. However I'm trying to think of some places where XML would be more appropriate as a protocol format, that doesn't include SOAP (because SOAP could theoretically be done with JSON anyways).

请注意:我爱我的XML用于许多其它目的,所以它不是有关XML VS JSON在一般情况下,我很担心尤其是AJAX的传输协议

Note: I love me XML for many other purposes, so its not about XML vs JSON in general, I'm concerned in particular with AJAX's transmission protocol.

推荐答案

这个问题是非常相似的<一href="http://stackoverflow.com/questions/325085/when-to-$p$pfer-json-over-xml">http://stackoverflow.com/questions/325085/when-to-$p$pfer-json-over-xml

不管怎样,我同意上面投票的答案有:

Anyhow, I agree with the top voted answer there:

我用JSON除非我需要使用XML。这是容易理解,和(因为它需要较少配置的开销),更容易编程用于读取和写入,如果库在上下文中可用​​,他们是pretty的无处不在了。

I use JSON unless I'm required to use XML. It's simpler to understand, and (because it requires less configuration overhead) easier to program for reading and writing if the libraries are available in your context, and they're pretty ubiquitous now.

在亚马逊第一次接触他们的产品目录为Web服务,他们提供既JSON和XML。像90%的实施者选择了JSON。

When Amazon first exposed their catalogs as a web service, they offered both JSON and XML. Something like 90% of the implementers chose JSON.

在事情的另一面,XML是很好的情况,其中...

On the flip side of things, XML is good for situations in which...

  • 您需要消息验证
  • 您正在使用XSLT
  • 您的邮件包含了大量的标记文本
  • 您需要互操作环境不支持JSON
  • 您需要的属性或命名空间

此也考虑从上面的问题,其实质上是要求这种相反

This is also taken from the question above, which is essentially asking the opposite of this.

这篇关于当你使用XML在JSON阿贾克斯?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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