我有这个数组Json,我怎么能得到对象的名字?这是我的数组 json:
var datos = {"animales":[
{
"nombre":"Lucy",
"animal":"Cat",
"breed":"American Shorthair",
"note":"She raised me"
},
{
"nombre":"Homer",
"animal":"Cat",
"breed":"unknown",
"note":"Named after a world-famous bassoonist"
},
{
"nombre":"Muchacha",
"animal":"Dog",
"breed":"mutt",
"note":"One of the ugliest dogs I’ve ever met"
}
]}
我怎么能得到钥匙的名字?(名词,动物,品种,注意)我正在尝试这种方式,但它不起作用:
for (key in datos) {
HtmlT += "<td>" + datos.animales[key]+ "</td>"; // it should return nombre
}
datos.animales[key] 返回 undefind