【发布时间】:2020-09-30 15:57:10
【问题描述】:
我是 JavaScript 的初学者,我想取消透视集合/数组。
我有一个这样的集合/数组:
[
{ 'produit': 'a', 'color': 'white', 'material': 'leather' },
{ 'produit': 'b', 'attribute': 'black', 'material': 'wool' }
]
我想转换我的集合/数组以获得类似的东西:
var a = [
{ 'produit': 'a', 'attribute': 'color', 'value': 'white' },
{ 'produit': 'a', 'attribute': 'material', 'value': 'leather' },
{ 'produit': 'b', 'attribute': 'color', 'value' :'black' },
{ 'produit': 'b', 'attribute': 'material', 'value': 'wool' }
]
我试图在 lodash.js 的文档中找到一些东西,但我不知道该怎么做。
【问题讨论】:
标签: javascript lodash unpivot