一:json的定义有
(1)数据在键值对中
(2)数据有逗号分隔
(3)花括号保存对象
(4)方括号保存数组
二:JSON值可以是:
(1)数字(整数或浮点数)
(2)字符串(在双引号中)
(3)逻辑值(true或false)
(4)对象(在花括号中)
(5)null
三:JSON的表示
(1)简单的表示
JSON数据的书写格式是:名称/值对 {“firstName”:“John”,“age”:"12"}
(2)表示数组
var people={
"programmers": [{
"firstName": "Brett",
"lastName": "McLaughlin",
"email": "aaaa"
}, {
"firstName": "Jason",
"lastName": "Hunter",
"email": "bbbb"
}, {
"firstName": "Elliotte",
"lastName": "Harold",
"email": "cccc"
}],
"authors": [{
"firstName": "Isaac",
"lastName": "Asimov",
"genre": "sciencefiction"
}, {
"firstName": "Tad",
"lastName": "Williams",
"genre": "fantasy"
}, {
"firstName": "Frank",
"lastName": "Peretti",
"genre": "christianfiction"
}]
}
(1)访问第二个authors中genre的值:people.authors[1].genre