• JSON is a valid subset of JavaScript, Python, and YAML
  • JSON parsing is generally faster than XML parsing.
  • JSON is a more compact format, meaning it weighs far less on the wire than the more verbose XML.
  • JSON is easier to work with in some languages (such as javascript, python, and php)
  • Formatted JSON is generally easier to read than formatted XML.
  • JSON specifies how to represent complex datatypes, there is no single best way to represent a data structure in XML.
  • JSON is a natural data structure for Javascript -- it is in fact javascript.  This makes it an easy and light model for data transfer <> server/services.
  • JSON is a nice format to extract XML data into. It's much nicer than extracting a big XML document...into a smaller XML document.
  • I am going to assuming that you asking about advantages of each format in the context of an ajax response. The biggest advantage for me is that JSON ends up being much, much easier to traverse, identify, and read nodes than XML. XML methods are cumbersome and long to write, while JSON is much more cruft and simple.
  • Helpful In the mobile context - it is also often less verbose than XML which helps to reduce bytes transferred.
  • More structural information in the document
    • Can easily distinguish between the number 1 and the string "1" as numbers, strings (and Booleans) are represented differently in JSON.
    • Can easily distinguish between single items and collections of size one (using JSON arrays).
  • Easier to represent a null value.
  • Easily consumed by JavaScript

Advantages of XML

  • Namespaces allow for sharing of standard structures
  • Better representation for inheritance
  • Standard ways of expressing the structure of the document: XML schema, DTD, etc
  • Parsing standards: DOM, SAX, StAX
  • Standards for querying: XQuery and XPath
  • Standards for transforming a document: XSLT

eg.

  to expand on the last point, the JSON object

{ "foo": { "bar": "baz" } }

could be represented in XML as

<foo bar="baz" .>

or

<foo><bar>baz</bar></baz>

or

<object name="foo">< property name="bar">baz</property ></object>

json数据相对于xml数据.的更多相关文章

  1. 如何使用Google APIs和Google应用系统集成(7)----在里面JSON兑换XML数据处理,JSON数据包括违规XML数据规范:XML节点名称不支持号码Java解

    笔者电话Google Calendar APIs的GetColors方法,其中(有关详细信息Google Calendar API已经Google API看到我的博文介绍的其余部分,目前,我们只取Go ...

  2. 【Flex】读取本地JSON,然后JSON数据转成XML数据

    package utils { import flash.xml.XMLDocument; import flash.xml.XMLNode; import mx.rpc.xml.SimpleXMLE ...

  3. Ajax--解析JSON数据与解析XML数据

    一.Ajax解析JSON数据 nav.json(json数据) [ { "link":"http://www.jd.com", "src": ...

  4. 把txt格式数据制作成xml数据

    txt格式数据: 代码: s1=""" <object> <name>{0}</name> <pose>Unspecifi ...

  5. 以对象的方式来访问xml数据表(三)

    怎样以对象的方式来访问xml数据表? 在讲如何具体实现(二)中所说的专门用于访问xml文件的动态链接库之前,我们先来看看这个动态链接库具体要实现什么功能. 动态链接库IXmlDB.dll的功能: 1. ...

  6. iOS开发网络篇—XML数据的解析

     iOS开发网络篇—XML数据的解析 iOS开发网络篇—XML介绍 一.XML简单介绍 XML:全称是Extensible Markup Language,译作“可扩展标记语言” 跟JSON一样,也是 ...

  7. WebService传递XML数据 C#DataSet操作XML 解析WebService返回的XML数据

    Webservice传递的数据只能是序列化的数据,典型的就是xml数据.   /// <summary>         /// 通过用户名和密码 返回下行数据         /// & ...

  8. tcp接收xml数据解析

    避免tcp接收xml数据时加上xml数据长度,根据xml数据特点来解析recv到的xml数据 int nPos1 = 0; int nPos2 = 0; int nTempPos = 0; int n ...

  9. 使用Java创建XML数据

    ------------siwuxie095                         工程名:TestCreateXML 包名:com.siwuxie095.xml 类名:CreateXML. ...

随机推荐

  1. C语言基础学习运算符-赋值运算符

    简单赋值 在C语言里,运算符=并不表示相等,而是一个赋值运算符.这意味着,符号=的左边该是一个可修改的变量名,而右边是赋给该变量的值. 如下程序语句: i = i+; 在数学上,该等式无法成立.而作为 ...

  2. 如何在django中使用多个数据库

    http://blog.chinaunix.net/uid-16728139-id-4364343.html 

  3. 关于Java中重载的若干问题

    一.问题引入 今天看视频时偶然间看到了,说父类和子类间也可以重载,貌似和以前的观念有些冲突,就验证了下…… 二.问题解决 看如下代码: public class Son extends Father ...

  4. 一】Maven入门

    一.简单pom.xml配置文件解析 <?xml version="1.0" encoding = "utf-8"?> <project xml ...

  5. github 提交报403 forbidden的错误解决

    github 提交报403 forbidden的错误解决 $ git push error: The requested URL returned error: 403 Forbidden while ...

  6. Currency Exchange(判断是否有正环)

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16456   Accepted: 5732 Description Seve ...

  7. Silverlight闹钟

    一:截图 二:XAML代码 <UserControl x:Class="SilverlightClock.MainPage" xmlns="http://schem ...

  8. Mac 下 Scala 平台搭建

    1.先要安装 JDK,下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html ...

  9. openSource clouds

    学习当前较主流的开源云基础设施管理软件by Ruiy summarize publish; 我擦,有不时候Ruiy干事也就那吊风格,啥事也就那么随口一说,你们太sensitivity,同网络延迟对存储 ...

  10. 数组在C++和java中的区别

    几乎所有的程序设计语言都支持数组.在C和C++中使用数组是很危险的.因为C和C++中的数组就是内存块.如果一个程序要访问其自身内存块之外的数组,或者在数组初始化之前使用它,都会产生难以预料的后果. j ...