案例:JSON案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>W3xue教程(w3xue.com)</title>
6
</head>
7
<body>
8
9
<p>访问 JSON 内嵌对象。</p>
10
11
<p id="demo"></p>
12
13
<script>
14
myObj = {
15
    "name":"W3xue",
16
    "alexa":10000,
17
    "sites": {
18
        "site1":"www.w3xue.com",
19
        "site2":"m.w3xue.com",
20
        "site3":"c.w3xue.com"
21
    }
22
}
23
document.getElementById("demo").innerHTML += myObj.sites.site1 + "<br>";
24
// 或者
25
document.getElementById("demo").innerHTML += myObj.sites["site1"];
26
</script>
27
28
</body>
29
</html>