When I load the page, I try to display the contents of the .json file, but the string [object Object][object Object][object Object][object Object][object Object] falls into the output. What am I doing wrong?
<div id="airport-list"></div> <script> $(function(){ $.getJSON('/json/airports.json', function(data) { $.each(data, function(i, field){ $('#airport-list').append(field + '' ); }); }); }); </script> You need to pull out the value of the ru field in the name_translations field in a row that looks like this:
{ "code":"SVO", "name":"Sheremetyevo International", "coordinates":{"lon":37.416573,"lat":55.966324}, "time_zone":"Europe/Moscow", "name_translations":{ "en":"Sheremetyevo International", "de":"Moskau-Scheremetjewo", "zh-CN":"谢列梅捷沃机场", "ru":"Шереметьево", "tr":"Şeremetyevo Uluslararası Havalimanı", "it":"Sheremetyevo", "fr":"Sheremetyevo", "es":"Sheremetyevo", "th":"สนามบินนานาชาติเชเรเมเตียโว" }, "country_code":"RU", "city_code":"MOW" }
field? give an example of the returned data - Igor