在之前的文章中我們講到了早期的集中數據格式,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,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。