Ajax和WEB服务数据格式:JSON与JSONP

  在之前的文章中我们讲到了早期的集中数据格式,XML,SOAP,HTML。现在,我们来看看JSON和JSONP。

  JSON

  JSON(JavaScript Object Notation)是Douglas Crockford提出的。他是一个轻量级的数据交换格式,基于JavaScript对象字面量。

  我们可以将之前的XML图书格式的文件内容转换成下面的JSON格式:

[
{
title:
"The Principles of Beautiful Web Design, 2nd Edition",
url:
"http://www.sitepoint.com/books/design2/",
author:
"Jason Beaird",
publisher:
"SitePoint",
price: {
currency:
"USD",
amount:
39.95
}
},
{
title:
"jQuery: Novice to Ninja",
url:
"http://www.sitepoint.com/books/jquery1/",
author:
"JEarle Castledine & Craig Sharkie",
publisher:
"SitePoint",
price: {
currency:
"USD",
amount:
29.95
}
},
{
title:
"Build Your Own Database Driven Website",
url:
"http://www.sitepoint.com/books/phpmysql4/",
author:
"Kevin Yank",
publisher:
"SitePoint",
price: {
currency:
"USD",
amount:
39.95
}
}
]

it知识库Ajax和WEB服务数据格式:JSON与JSONP,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。