所以我有一个像这样的JSON数组
[ { _id: 59457ae28fbbbf3bc4420019,
name: 'asdasd',
comment: 'asdadada' },
{ _id: 59457aec8fbbbf3bc442001a,
name: 'asdui',
comment: 'huihgsbdiuagbsdiuagb as' },
{ _id: 59457aec8fbbbf3bc442001b,
name: 'asdui',
comment: 'huihgsbdiuagbsdiuagb asdad' },
{ _id: 59457af08fbbbf3bc442001c,
name: 'asdbhajs',
comment: 'bhjasbd' },
{ _id: 59457ce5500a7e3d99a20a0f,
name: 'asdad',
comment: 'asdaffasfaf' },
{ _id: 59457d089effc03e1bb75304,
name: 'asdas',
comment: 'sadasdasdasd' },
{ _id: 594589bb2cbac34aa27d89cd,
name: 'er',
comment: 'asdasdasd' } ]
现在的问题是,当我尝试从中获取一个元素时,我无法得到它,因为[]
阻碍了它,这是不必要的。有没有办法通过使用功能删除?
答案 0 :(得分:0)
这不是JSON;这是一个javascript数组。您可以将其作为数组访问:
foreach ( var item of myArray )
{
console.log('ID:', item._id, 'Name:', item.name, 'Comment:', item.comment);
}