• 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. JVM笔记-temp

    jvm源码分析之堆外内存完全解读 http://lovestblog.cn/blog/2015/05/12/direct-buffer/

  2. TCP状态转换图

    注意: connect函数导致当前套接字从CLOSE状态(该套接字自从由socket函数创建以来一直所处的状态)转移到SYN_SENT状态 若成功则再转移到ESTABLISHED状态, 若connec ...

  3. 1001WA

    时间关系只实现了其中一部分的功能  现在的程序可以实现一个大数的平方 #include <stdio.h> #include <string.h> void mypower(i ...

  4. Instruments 使用指南

    Instruments 用户指南 http://cdn.cocimg.com/bbs/attachment/Fid_6/6_24457_90eabb4ed5b3863.pdf 原著:Apple Inc ...

  5. Swift中使用构建配置来支持条件编译-b

    在Objective-C中,我们经常使用预处理指令来帮助我们根据不同的平台执行不同的代码,以让我们的代码支持不同的平台,如: 1 2 3 4 5 6 7 8 9 #if TARGET_OS_IPHON ...

  6. iPhone 被同步到 Mac上后 如果不希望更新到Mac上在哪里删除?

    前往文件夹   /Users/用户名/Library/Application Support/MobileSync  直接删除  就行了(同时要倾倒废纸篓). 目前iPhone链接Mac 后  不让 ...

  7. Topk引发的一些简单的思考

    软件工程课程的一个题目:写一个程序,分析一个文本文件中各个词出现的频率,并且把频率最高的10个词打印出来.文本文件大约是30KB~300KB大小. 首先说一下这边的具体的实现都是在linux上实现的. ...

  8. 转:Eclipse Kepler已支持Java 8

    文章来自于:http://www.infoq.com/cn/news/2014/04/eclipse-kepler-support-java8 期待已久的Java 8已于2014年3月19日正式发布, ...

  9. temp gbk2utf8

    __author__ = 'root' # -*- coding: utf-8 -*- ps = '/data/poitestdata/行政地名.csv' pt = '/data/poitestdat ...

  10. cf C. Counting Kangaroos is Fun

    http://codeforces.com/contest/373/problem/C 贪心,先排序,然后从n/2位置倒着找每一个可不可以放到别的袋鼠内. #include <cstdio> ...