码迷,mamicode.com
首页 > Web开发 > 详细

json数据的读取

时间:2016-02-24 20:48:38      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Document</title>
    <script>
        window.onload = function(){
             var country =
                {
                    name: "中国",
                    provinces: [
                        { name: "黑龙江", citys: { city: ["哈尔滨", "大庆"]} },
                        { name: "广东", citys: { city: ["广州", "深圳", "珠海"]} },
                        { name: "台湾", citys: { city: ["台北", "高雄"]} },
                        { name: "新疆", citys: { city: ["乌鲁木齐"]} }
                    ]
                }
          // document.write(country.name);//中国
          // document.write(country.provinces[0].name);//黑龙江
          document.write(country.provinces[2].citys.city[0]);//台北
        }
    </script>
</head>
<body>
    
</body>
</html>

 

json数据的读取

标签:

原文地址:http://www.cnblogs.com/bybelief/p/5213991.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!