【发布时间】:2021-04-03 04:37:48
【问题描述】:
我的数组看起来像,但包含 1000 多个对象:
data = {
0: {
code: '3019476',
_id: '60033f61-8a4e-4622-9731-decd07bc44e1',
vendor: 'DKNY',
tags: [
{ type: 1, label: 'dsfs' },
{ type: 2, label: 'thisOne' },
{ type: 3, label: 'sdas' },
],
},
1: {
code: '3019475',
_id: '60033f61-8a4e-4622-9731-decd07bc44e0',
vendor: 'DKNY',
tags: [
{ type: 1, label: 'sdfsd' },
{ type: 2, label: 'anotherOne' },
{ type: 3, label: 'sdfsd' },
],
},
2: {
code: '3019474',
_id: '60033f61-8a4e-4622-9731-decd07bc44e9',
vendor: 'DKNY',
tags: [
{ type: 1, label: 'gregf' },
{ type: 2, label: 'thisOne' },
{ type: 3, label: 'gregf' },
],
},
};
我希望这是输出:
0: {title: "thisOne", data: Array(2)"}
1: {title: "anotherOne", data: Array(1)"}
所以我想过滤和统计有多少对象包含不同的标签[1].label,将完整的项目数据保存在结果中的“数据”中。
我所有的想法都失败了,所以我真的需要你的帮助
【问题讨论】:
-
data有很多语法错误,请尝试修复它们 -
请在问题中包含您失败的想法。它可以帮助人们回答您的问题,也可以帮助您从中了解更多信息。
标签: javascript arrays underscore.js