baidu.json 里面的
{
"count": 4,
"isbaidu": false,
"isok": true,
"0": {
"x": 9824271,
"y": 3006396,
"t": 1354873078
},
"1": {
"x": 9824277,
"y": 3006474,
"t": 1354872772
},
"2": {
"x": 9824330,
"y": 3006481,
"t": 1354872752
},
"3": {
"x": 9830686,
"y": 3005521,
"t": 1354871415
}
}
html代码
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<script type="text/javascript" src="jquery.js"></script>
<title></title>
</head>
<body>
<div id="allmap"></div>
<script type="text/javascript">
$.getJSON("baidu.json",function(json){
alert(json.count);//输出数据 4
alert("JSON Data: " + json[0].x); //输出数据 9824271
//(不是按数据下标计算,而是以键值对的形式获取"0": { "x": 9824271, "y": 3006396, "t": 1354873078}, 里面的X值)
alert("JSON Data: " + json['0'].x); //输出数据 9824271
});
</script>
</body>
</html>