|
xml的寫法:
<contact>
<friend>
<name>Michael</name>
<email>[email protected]</email>
<homepage>http://www.jialing.NET</homepage>
</friend>
<friend>
<name>John</name>
<email>[email protected]</email>
<homepage>http://www.john.com</homepage>
</friend>
<friend>
<name>Peggy</name>
<email>[email protected]</email>
<homepage>http://www.peggy.com</homepage>
</friend>
</contact>
那json怎么寫呢?
JSON:
[
{
name:"Michael",
email:"[email protected]",
homepage:"http://www.jialing.NET"
},
{
name:"John",
email:"[email protected]",
homepage:"http://www.jobn.com"
},
{
name:"Peggy",
email:"[email protected]",
homepage:"http://www.peggy.com"
}
]
可以很明顯的看出:
JSON的格式:
1,對象:
{name:"Peggy",email:"[email protected]",homepage:"http://www.peggy.com"}
{ 屬性 : 值 , 屬性 : 值 , 屬性 : 值 }
2,數組是有順序的值的集合。一個數組開始于"[",結束于"]",值之間用","分隔。
[
{name:"Peggy",email:"[email protected]",homepage:"http://www.peggy.com"}, {name:"Peggy",email:"[email protected]",homepage:"http://www.peggy.com"},
{name:"Peggy",email:"[email protected]",homepage:"http://www.peggy.com"}
]
3, 值可以是字符串、數字、true、false、null,也可以是對象或數組。這些結構都能嵌套。
本篇文章來源于 cssrain.cn 原文鏈接:http://www.cssrain.cn/article.ASP?id=488
JavaScript技術:json 定義,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。