<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
var a={
"1":10,
"2":12
};
/*遍历*/
for(var b in a){
alert(a[b])
}
var a={
"yi":1
"er":2
"san":3
"si":{
"yi":11
}
}
console.log(a["si"]["yi"])
var nianji={
"yi":"一年级",
"er":"二年级",
"san":"三年级"
};
var banji={
"一年级":{
"yi":"一年级一班",
"er":"一年级二班",
"san":"一年级三班"
},
"二年级":{
"yi":"二年级一班",
"er":"二年级二班",
"san":"二年级三班"
},
"三年级":{
"yi":"三年级一班",
"er":"三年级二班",
"san":"三年级三班"
}
};
var tongxie={
"一年级一班":{
"yi":"张三",
"er":"李四",
"san":"王五"
},
"一年级二班":{
"yi":"张三",
"er":"李四",
"san":"王五"
},
"一年级三班":{
"yi":"张三",
"er":"李四",
"san":"王五"
},
"二年级一班":{
"yi":"张三",
"er":"李四",
"san":"王五"
},
"二年级二班":{
"yi":"张三",
"er":"李四",
"san":"王五"
},
"二年级三班":{
"yi":"张三",
"er":"李四",
"san":"王五"
},
"三年级一班":{
"yi":"张三",
"er":"李四",
"san":"王五"
},
"三年级二班":{
"yi":"张三",
"er":"李四",
"san":"王五"
},
"三年级三班":{
"yi":"张三",
"er":"李四",
"san":"王五"
}
};
console.log(tongxie[banji[nianji["er"]]["er"]])
//json数组嵌套
var dataString={
"teachers":[
{"name":"黄波","course":"网页高级设计"},
{"name":"贺敏","course":"Java程序设计"},
{"name":"毛丽娟","course":"JavaScript程序设计"}
],
"students":[
{"name":"张三","age":20},
{"name":"李四","age":21},
{"name":"王五","age":19}
]
};
console.log(dataString["students"][2]["name"])
</script>
</body>
</html>