收到 JSON 响应
[{
"name": "A1",
"date": "2019-03-13",
"comment": "xyz"
},
{
"name": "A1",
"date": "2019-03-13",
"comment": "abc"
},
{
"name": "B1",
"date": "2019-03-13",
"comment": "pqr"
},
{
"name": "A1",
"date": "2019-03-14",
"comment": "mno"
}
]
期望输出
[
{
"name": "A1",
"date": "2019-03-13",
"data": [
{
"name": "A1",
"date": "2019-03-13",
"comment": "xyz"
},
{
"name": "A1",
"date": "2019-03-13",
"comment": "abc"
}
],
{
"name": "A1",
"date": "2019-03-14",
"data": [
{
"name": "A1",
"date": "2019-03-14",
"comment": "mno"
}
]
},
{
"name": "B1",
"date": "2019-03-13",
"data": [
{
"name": "B1",
"date": "2019-03-13",
"comment": "pqr"
}
]
}
]
我想创建一个包含唯一名称和日期及其相应数据的新javascript数组。
有人可以帮帮我吗?