【发布时间】:2016-07-05 14:03:25
【问题描述】:
我正在尝试简化复杂的结构。
我已经尽可能地简化了它并将其简化为:
[
{'Cells':{'Results':[
{'Key':'ID','Value':123},
{'Key':'Color','Value':'Red'},
{'Key':'Direction','Value':'West'}
]}},
{'Cells':{'Results':[
{'Key':'ID','Value':456},
{'Key':'Color','Value':'Green'},
{'Key':'Direction','Value':'East'}
]}}
]
我的 lodash 缺乏技能,我需要帮助将上述内容变成这样:
[
{'ID':123, 'Color':'Red', 'Direction':'West'},
{'ID':456, 'Color':'Green', 'Direction':'East'}
]
顺便提一下,键的数量因对象而异。至少,它可能只有 ID,但有些可能会超过示例中的这三个。
【问题讨论】:
标签: javascript arrays object underscore.js lodash