Is it possible to map JSON objects with duplicate id values to their association property in an array using JavaScript after a join operation?
{
"id": 1,
"name": "doc 1",
"appointmentTime": "2018-12-28T00:00:43"
},
{
"id": 2,
"name": "doc 2",
"appointmentTime": "2018-12-25T23:00:53"
},
{
"id": 2,
"name": "doc 2",
"appointmentTime": "2018-12-26T23:00:02"
},
{
"id": 3,
"name": "doc3",
"appointmentTime": null
},
Desired output:
{
"id": 1,
"name": "doc1",
"appointmentTime": ["2018-12-28T00:00:43"]
},
{
"id": 2,
"name": "doc 2",
"appointmentTime": ["2018-12-26T23:00:02","2018-12-26T23:00:02"]
},
{
"id": 3,
"name": "doc3",
"appointmentTime": null
},