我想從下面的json中獲取subdivisions.names.en,但不斷收到「TypeError:location.subdivisions.names is undefined」錯誤。我敢肯定它的東西簡單&概率只是需要更多的睡眠;)如何從json中提取特定信息
我能得到其他我需要的信息 - 這工作:
alert(location.city.names.en + ' ' + location.postal.code);
但這並不:
alert(location.subdivisions.names.en);
這裏是我的JSON:
{
"continent": {
"code": "OC",
"geoname_id": xxx,
"names": {
"fr": "Océanie",
"pt-BR": "Oceania",
"zh-CN": "大洋洲",
"es": "Oceanía",
"de": "Ozeanien",
"ja": "オセアニア",
"en": "Oceania",
"ru": "Океания"
}
},
"location": {
"longitude": xxxx,
"latitude": -xxxx,
"time_zone": "Australia/Melbourne"
},
"subdivisions":
[
{
"names": {
"ru": "Виктория",
"pt-BR": "Vitória",
"en": "Victoria"
},
"iso_code": "VIC",
"geoname_id": xxxx
}
],
}
我必須得到更多的睡眠 - 謝謝你:) – MWD