我有这个 json 响应,其中 obj.attributes 列出了以下内容。我只想遍历每个对象,而这些对象又具有 ids ..我如何遍历对象并打印 id 属性
Object {0: Object, 1: Object, 2: Object, 3: Object, subject_Keys: "", schoolapplication: Object}
我试过了
for(var item in obj.attributes)
{
var intRegex = /^\d+$/;
if(intRegex.test(item)) {
console.log(obj.attributes[item]["id"]) //This prints undefined
}
}
编辑1:console.log(obj)
child {cid: "c33", changed: Object, attributes: Object, _changes: Array[0], _hasComputed: true…}
_changes: Array[0]
_changing: false
_currentAttributes: Object
_hasComputed: true
_pending: false
_previousAttributes: Object
app_id: 8
attributes: Object
changed: Object
cid: "c33"
__proto__: Surrogate
console.log(obj.attributes)
Object {0: Object, 1: Object, 2: Object, 3: Object, subject_Keys: "", schoolapplication: Object}
0: Object
name: "key1"
schoolapplication: Object
id: 3
__proto__: Object
1: Object
2: Object
3: Object
__proto__: Object