JS – 如何将所有键转换为其值(从对象)

我有这样的事情(即时通讯从API获取,所以我不能改变它):

{ one: [ { price: ['$10'], weight: ['1000'], color: ['red'] } ], two: [ { price: ['$20'], weight: ['2000'], color: ['green'] } ], three: [ { price: ['$30'], weight: ['3000'], color: ['blue'] } ] } 

我想将所有“价格”,“重量”和“颜色”键转换为其值,看起来像这样:

 { one: [ '$10', '1000', 'red' ], two: [ '$20', '2000', 'green' ], three: [ '$30', '3000', 'blue' ] } 

有没有简单的方法来做到这一点?

编辑:示例修复
编辑2:通缉的结果固定

你可以映射使用键和映射想要的属性forms内部数组。

 var object = { one: [ { price: ['$10'], weight: ['1000'], color: ['red'] } ], two: [ { price: ['$20'], weight: ['2000'], color: ['green'] } ], three: [ { price: ['$30'], weight: ['3000'], color: ['blue'] } ] }; Object.keys(object).forEach(function (k) { object[k] = [ 'price', 'weight', 'color'].map(function (p) { return object[k][0][p][0]; }); }); console.log(object); 
 .as-console-wrapper { max-height: 100% !important; top: 0; }