Why to use JSON?
来源:互联网 发布:一带一路 就业 知乎 编辑:程序博客网 时间:2024/04/29 20:08
Why to use JSON?
Accroading to www.json.org, you can know that It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. So we should use json instead of xml in javascript. As we know, javascript is a scripting language, so it need speed many resource to parse xml string. If we want to parse xml string, We need create DOMParser object first, then use the object to parse the xml string. It is very hard to master. However, we can easy to do this with JSON.
For example:
XML:
<cmd op="CreateObject">
<ID>007</ID>
<Name>new object</Name>
<Attribute>
<CreateTime>2007-8-31</CreateTime>
<ModifyTime>2007-8-31</ModifyTime>
</Attribute>
</cmd>
JSON:
{cmd:{op:CreateObject,ID:007,Name:new object,Attribute:{CreateTime:2007-8-31, ModifyTime:2007-8-31}}}
How to get the object name with xml?
var doc = parser.ParserFromString(xmlstring, "text/xml");
var objectName = doc.documentElement.getElementsByTagName("Name").item(0).nodeValue;
However, It's very easy to get the object name with json.
Which way you like?
- Why to use JSON?
- Why to use JSON?
- Why and How to Use Netlink Socket
- Linux Why and How to use NetLink
- Why and How to Use Netlink Socket
- Why and How to Use Netlink Socket
- Why Ceph and how to use Ceph?
- Why bootstrap/How to use bootstrap
- Why to use memory pool and how to implement it
- Kernel Korner - Why and How to Use Netlink Socket
- Kernel Korner - Why and How to Use Netlink Socket
- Kernel Korner - Why and How to Use Netlink Socket
- Use YSlow to know why your web Slow
- Why do I need to use DAC from Oracle BI?
- Kernel Korner - Why and How to Use Netlink Socket
- Kernel Korner - Why and How to Use Netlink Socket
- How-to: Use HBase Bulk Loading, and Why
- ceph存储 Why Ceph and how to use Ceph?
- DB Control 编写
- 试试看
- 第二章 PL/SQL基础
- TestComplete的Stores对象
- 一位美国人的简历
- Why to use JSON?
- 不可量化的价值
- readyState的五种状态
- Mysql命令&&MySQL常用操作命令
- CMM的本质
- Notification和FreeNotification
- MySQL实用命令
- 这些所谓的文人专家都该枪毙【原创】
- 共看海天成一色——河北乐亭游记(预热篇)