我是一个非常大的 n00b,使用 javascript 和 jquery,所以我在这里尽我所能。我有来自 Stackmob 查询的 JSON 返回。我需要知道如何从这个 JSON 字符串中正确获取name
、和distance
,以便我可以在 google api 调用中进一步使用它们。lat
lon
[
{
"name": "eBay",
"lat_long": {
"lon": -121.927551,
"lat": 37.29546,
"distance": 0.004635090828588474
},
"locations_id": "a3563711ebb44a088ae5ab2bd7ff2e0e"
},
{
"name": "Facebook",
"lat_long": {
"lon": -121.894955,
"lat": 37.339386,
"distance": 0.005523591746943001
},
"locations_id": "3fbee8e363bf4247b2e8ca0958c38f4e"
},
{
"name": "Yahoo",
"lat_long": {
"lon": -122.025159,
"lat": 37.417237,
"distance": 0.006310220058572611
},
"locations_id": "d0c568a6322f4a3b8d2fe30cba68f8f1"
},
{
"name": "Hewlett Packard",
"lat_long": {
"lon": -122.145989,
"lat": 37.415515,
"distance": 0.006312489443257717
},
"locations_id": "f03676c3469d4b978bfefcb2ab13790d"
},
{
"name": "Google",
"lat_long": {
"lon": -122.083979,
"lat": 37.421931,
"distance": 0.006351811575525541
},
"locations_id": "56325f71322a4c70ab0e3f1b3fb7fd9b"
}
]
我的返回对象是model
,我尝试通过循环 model[i].name 等进行引用,但在 firebug 中获取空字符串。