【发布时间】:2016-11-21 04:11:37
【问题描述】:
我有以下结构:
var output = [{
"article": "BlahBlah",
"title": "Another blah"
}, {
"article": "BlahBlah",
"title": "Return of the blah"
}, {
"article": "BlahBlah2",
"title": "The blah strikes back"
}, {
"article": "BlahBlah2",
"title": "The blahfather"
}]
从上面使用优雅的 lodash 单线,我需要创建以下结构。
var newOutput = [{
"article": "BlahBlah",
"titles": ["Another blah", "Return of the blah"]
}, {
"article": "BlahBlah2",
"titles": ["The blah strikes back", "The blahfather"]
}]
非常感谢您一如既往的帮助。解释解决方案的工作原理是一个巨大的优势。
【问题讨论】:
-
titles如果只有一条记录,应该是数组吗? -
房产真的是
'title:'吗? -
@NinaScholz.. 很好发现
标签: javascript arrays object lodash