从Google Map解析JSON

我想显示这个json的地方细节:我有解析它的问题,我想获得“网站”,“名称”和“评级”。 这是JSON链接: https://maps.googleapis.com/maps/api/place/details/json?reference=CpQBjAAAAHDHuimUQATR6gfoWNmZlk5dKUKq_n46BpSzPQCjk1m9glTKkiAHH_Gs4xGttdOSj35WJJDAV90dAPnNnZK2OaxMgogdeHKQhIedh6UduFrW53wtwXigUfpAzsCgIzYNI0UQtCj38cr_DE56RH4Wi9d2bWbbIuRyDX6tx2Fmk2EQzO_lVJ-oq4ZY5uI6I75RnxIQJ6smWUVVIHup9Jvc517DKhoUidfNPyQZZIgGiXS_SwGQ1wg0gtc&sensor=true&key=AIzaSyDSKYz8pCRLHglMPGo1ca6E-geDUQwFNQ8 。

{ "html_attributions": [ "Źródło wpisów: Yellow Pages" ], "result": { "address_components": [ { "long_name": "10", "short_name": "10", "types": [ "street_number" ] }, { "long_name": "Darling Drive", "short_name": "Darling Drive", "types": [ "route" ] }, { "long_name": "Darling Harbour, Sydney", "short_name": "Darling Harbour, Sydney", "types": [ "locality", "political" ] }, { "long_name": "NSW", "short_name": "NSW", "types": [ "administrative_area_level_1", "political" ] }, { "long_name": "AU", "short_name": "AU", "types": [ "country", "political" ] }, { "long_name": "2000", "short_name": "2000", "types": [ "postal_code" ] } ], "formatted_address": "Harbourside Centre 10 Darling Drive, Darling Harbour, Sydney NSW, Australia", "formatted_phone_number": "(02) 9211 8900", "geometry": { "location": { "lat": -33.871983, "lng": 151.199086 } }, "icon": "http://sofzh.miximages.com/javascript/restaurant-71.png", "id": "677679492a58049a7eae079e0890897eb953d79b", "international_phone_number": "+61 2 9211 8900", "name": "Zaaffran Restaurant - BBQ and GRILL, Darling Harbour", "rating": 3.9, "reference": "CpQBjAAAAARBNvpI6EgL3AuRxjwEMz9Va2gFaByrv-0GdqcoZ2QnyfmJiwEX1MLv2uCofWPqxkHPWQNwskrRD58LgD7egsuGooWPDmd2v1Xmt1YTLH0NF0yhXPfSiK62n6m2elI8u6h6FUW6eKJdQVGKLeRfLHl-Ezw_ML1kL4srZ80xuFZNWVmUyHWN2H5BDhhpGI4NwxIQAr5S5g1x1v4WvxS-zq2YBxoU0pVhJe6lLnkKDmm8fgYObLakvL8", "types": [ "restaurant", "food", "establishment" ], "url": "http://maps.google.com/maps/place?cid=14075582311174685259", "vicinity": "Harbourside Centre 10 Darling Drive, Darling Harbour, Sydney", "website": "http://www.zaaffran.com/" }, "status": "OK" 

}

我试着使用这个function:

 $(document).ready(function() { $.getJSON('GOOGLE URL HERE', function(data) { $('#dictionary').empty(); $.each(data, function(entryIndex, entry) { var html = '
'; html += '

' + entry['name'] + '

'; html += '
' + entry['website'] + '
'; html += '
'; html += entry['rating']; html += '
'; html += '
'; $('#dictionary').append(html); }); }); return false;

});

它对我不起作用。 请帮助我,非常感谢。 米哈尔

更换:

  $.each(data, function(entryIndex, entry) { var html = '
'; html += '

' + entry['name'] + '

'; html += '
' + entry['website'] + '
'; html += '
'; html += entry['rating']; html += '
'; html += '
'; $('#dictionary').append(html); });

有:

  var html = '
'; html += '

' + data.result['name'] + '

'; html += '
' + data.result['website'] + '
'; html += '
'; html += entry['rating']; html += '
'; html += '
'; $('#dictionary').append(html);

each都不需要。 使用data.result.name直接访问数据,因为data是单个对象以及result