我对lodash缺乏经验,但我相信它可以帮助我将数据转换为所需的格式.我已经尝试过文档中描述的不同级别的方法,但我无法绕过一切.我在这里看过SO,一些博客和文档.我尝试过将groupby和map结合起来,但我无法解决问题.我也不确定如何记录这些步骤.
这是我想要做的,我想采取以下数组并将其转换为数组.谁能指出我正确的方向?
原始数据
var mockData = [
{
"notice_title": "Bad news",
"notice_text": "Server is down!",
"start_date": "2016-09-18T04:00:00Z"
},
{
"notice_title": "Weekly Reminder",
"notice_text": "Please read the assignment!",
"start_date": "2016-09-18T04:00:00Z"
},
{
"notice_title": "Sweet",
"notice_text": "This morning, the new edition of our blog hit stands!",
"start_date": "2016-09-19T04:00:00Z"
},
{
"notice_title": "Yeah",
"notice_text": "This is pretty cool",
"start_date": "2016-09-19T04:00:00Z"
}
Run Code Online (Sandbox Code Playgroud)
期望的数据
var newMockData = [
{
"date": "JAN 18 2016",
"messages": [{
"notice_title": "Bad news",
"notice_text": "Server is down!",
"start_date": "2016-09-18T04:00:00Z"
}, …Run Code Online (Sandbox Code Playgroud)