真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

json數(shù)據(jù)格式

JSON數(shù)據(jù)格式

成都創(chuàng)新互聯(lián)公司于2013年成立,先為禹城等服務建站,禹城等地企業(yè),進行企業(yè)商務咨詢服務。為禹城企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務解決您的所有建站問題。

ex01

/*

*類對象,封閉成員屬性

*classPeople{

*Stringfirstname

*Stringlastname

*Stringemail

*}

*

*Peoplepeople=newPeople();

*

*people.firstname

*people.lastname

*people.email

*

*/

/*

*json格式表示一個對象,鍵值相對

*格式:{key01:value01,key02:value02}

*

*/

varpeople={"firstname":"zhang","lastname":"sanfeng","email":"keni@com"}

//alert("people"+people)

//alert("people")

////輸出peopel的first屬性的值,即zhang

alert("名:"+people.firstname);

//輸出peopel的lastname屬性的值,即sanfeng

alert("姓:"+people.lastname);

//輸出peopel的email屬性的值,即keni@com

alert("電子郵箱:"+people.email);

ex02

/*

*json格式表示一個對象

*格式:[

*{key01:value01,key02:value02},

*{key01:value01,key02:value02}

*]

*

*/

//json數(shù)組集合,存放兩個對象,每個對象有三個屬性

varpeople=[

{"firstname":"zhang1","lastname":"sanfeng1","email":"keni1@com"},

{"firstname":"zhang2","lastname":"sanfeng2","email":"keni2@com"}

]

alert("對象長度"+people.length);//長度為2

//輸出對象數(shù)組中第二個對象的lastname屬性

alert("第二個對象的lastname屬性:"+people[1].lastname);//輸出zhang2

ex03

/*

*json格式表示一個對象

*格式:{key:

*[

*{key01:value01,key02:value02},

*{key01:value01,key02:value02}

*]

*}

*

*/

varpeople={"program":

[

{"firstname":"zhang1","lastname":"sanfeng1","email":"keni1@com"},

{"firstname":"zhang2","lastname":"sanfeng2","email":"keni2@com"}

]

}

alert(people.program.length);//輸出program的長度為2

alert(people.program[1].lastname);//輸出people對象中program屬性中第二個對象的lastname

ex04

/*

*json格式表示一個對象

*格式:{key1:

*[

*{key01:value01,key02:value02},

*{key01:value01,key02:value02}

*],

*key2:

*[

*{key01:value01,key02:value02},

*{key01:value01,key02:value02}

*]

*}

*

*/

varpeople={"program1":

[

{"firstname":"zhang11","lastname":"sanfeng11","email11":"keni1@com"},

{"firstname":"zhang12","lastname":"sanfeng12","email12":"keni2@com"}

],

"program2":

[

{"firstname":"zhang21","lastname":"sanfeng21","email":"keni21@com"},

{"firstname":"zhang22","lastname":"sanfeng22","email":"keni22@com"}

],

"program3":

[

{"firstname":"zhang31","lastname":"sanfeng31","email":"keni31@com"},

{"firstname":"zhang32","lastname":"sanfeng32","email":"keni32@com"}

]

}

//輸出people對象program3對象中第一個對象的last的值

alert(people.program3[0].lastname);

ex05

varpeople={

"username":"zhang",

"sex":"male",

"tel":{"phone":"110","cell":"13812345678"},

"address":[

{"city":"tieling","postcode":"110"},

{"city":"beijing","postcode":"100"}

]

}

alert(people.username);

alert(people.tel.cell);

alert(people.address[1].city);

alert(people.address[1].postcode)


當前標題:json數(shù)據(jù)格式
轉(zhuǎn)載來源:http://weahome.cn/article/iigpgj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部