获取json数据
<script>
varjson=
[{"nam物报环e":"Lee","sex":"male"},{"age":"21","hobit":"baskeyball"}]
alert(json[0].name)
//json[0]就是{"name":"Lee","sex":"male"}
//json[1]就是{"age":"21","hobit":"baskeyball"}
</script>
<script>
Va来自rjson=
[{"name":[{"firstna夫味振美新被王许汉me":"Lee","lastname":"min"}],"sex":"male"},{"age":"21","hobit":"baskeyball"}]
alert(jso述花终热n[0].name[0].firstname);
//json[0]就是{"name":"Lee","sex":"male"}
//json[0].name[0]就是{"firstname":"Lee","lastname":"min"}
//json[1]就是{"age":"21","hobit":"baskeyball"}
</script>
补脑专用:json一般是对象的集合,相当于java的list集合立一样,
语法:varjson=[策以项低杆晚怎{"name":"Lee","s360问答ex":"male"},{"hobit":"tennis"}]
//json最外面是中括号,里面是由花括号组成的对象,对象之间用逗号隔开,对象快渐西推取里面有属性,属性之间以逗号隔开
标签:json,获取,数据