我有一个像这样的对象,我想从中获取“属性”数组并将其存储到新变量中。
obj = {
"_id": "5bf7e1be80c05307d06423c2",
"agentId": "awais",
"attributes": [ // that array.
{
"createdDate": "2018-11-23T11:17:18.771Z",
"_id": "5bf7e1be80c05307d06423c4",
"name": "Marketing",
"description": "Arabic Language Attribute",
"type": "Boolean",
"value": "true",
"usageCount": 0
},
{
"createdDate": "2018-11-23T11:17:18.770Z",
"_id": "5bf7e1be80c05307d06423c3",
"name": "English",
"description": "English Language Attribute",
"type": "Proficiency",
"value": "7",
"usageCount": 0
}
],
"__v": 0
}
答案 0 :(得分:0)
我不确定我的意思是对的,但是如果您要访问对象并获取数组数据,则可以这样操作:
假设您的json对象保存在var“ jsonObject”变量中,则可以得到如下数组值:
var tempArray = jsonObject['attributes'];