中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

json數據格式

發布時間:2020-06-29 10:54:30 來源:網絡 閱讀:554 作者:yixiaoqun 欄目:web開發

JSON數據格式

ex01

<scriptlanguage="JavaScript">

/*

*類對象,封閉成員屬性

*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")

////輸出peopelfirst屬性的值,zhang

alert(":"+people.firstname);

//輸出peopellastname屬性的值,sanfeng

alert(":"+people.lastname);

//輸出peopelemail屬性的值,keni@com

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

</script>

ex02

<scriptlanguage="JavaScript">

/*

*json格式表示一個對象

*格式:[

*{key01:value01,key02:value02},

*{key01:value01,key02:value02}

*]

*

*/

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

varpeople=[

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

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

]

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

//輸出對象數組中第二個對象的lastname屬性

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

</script>

ex03

<scriptlanguage="JavaScript">

/*

*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

</script>

ex04

<scriptlanguage="JavaScript">

/*

*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);

</script>

ex05

<scriptlanguage="JavaScript">

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)

</script>

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

永清县| 洪雅县| 海口市| 兴城市| 北京市| 鄂温| 麻江县| 达孜县| 竹溪县| 稷山县| 河北区| 从化市| 镇平县| 巴彦淖尔市| 天峻县| 原阳县| 任丘市| 兴山县| 旬邑县| 巴彦淖尔市| 罗平县| 肇源县| 乐至县| 辽宁省| 鹤壁市| 嘉善县| 曲阜市| 武清区| 四子王旗| 沈丘县| 兴国县| 平邑县| 昌图县| 邢台市| 甘谷县| 儋州市| 铜鼓县| 宁夏| 赣榆县| 公主岭市| 遵化市|