初学者同时使用JSON和javascript.我需要一种方法从对象列表而不是他的值返回它自己的键 subAttributeOne
.
以下是列表的示例,
var list =
[
{
attribute1: "value",
attribute2:[{subAttributeOne:"value",subAttributeTwo:"value"},{}]
},
//other objects
{..}
]
Run Code Online (Sandbox Code Playgroud)
我试过跟着,
list[0].attribute2[1].subAttributeOne
Run Code Online (Sandbox Code Playgroud)
它返回value
但我需要的结果是subAttributeOne