我已经尝试了所有我能想到的东西来获取数据,但无法解决这个问题。
数据的结构如下:
[{"code":1000,"day":"Sunny","night":"Clear","icon":113,"languages":
[{"lang_name":"Arabic","lang_iso":"ar","day_text":"مشمس","night_text":"صافي"}]
}]
我尝试使用key:value使用点表示法和括号表示法进行循环,但无法获取信息。
我试图了解"语言"所以我可以解析它们的天气。
答案 0 :(得分:2)
var arr = [{"code":1000,"day":"Sunny","night":"Clear","icon":113,"languages":
[{"lang_name":"Arabic","lang_iso":"ar","day_text":"مشمس","night_text":"صافي"}]
}]
arr.forEach(function(obj){ //loop array
obj.languages.forEach(function(language) { //loop languages
console.log(language); //language object
console.log(language.lang_name); //language property
});
});