I have an array below like this
[
  {
    "Date": "2020-07",
    "data": [
      {
        "id": "35ebd073-600c-4be4-a750-41c4be5ed24a",
        "Date": "2020-07-03T00:00:00.000Z",
        "transactionId": "13",
        "transactionType": "Payment",
        "amount": 1500
      }
    ]
  },
  {
    "Date": "2020-07",
    "data": [
      {
        "id": "4e126519-e27b-4e82-bb81-689c7dc63c9b",
        "Date": "2020-07-02T00:00:00.000Z",
        "transactionId": "4",
        "transactionType": "Payment",
        "amount": 1000
      }
    ]
  },
  {
    "Date": "2020-06",
    "data": [
      {
        "id": "646d6497-9dea-4f27-896e-a45d97a252ea",
        "Date": "2020-06-04T00:00:00.000Z",
        "transactionId": "14",
        "transactionType": "Payment",
        "amount": 1500
      }
    ]
  },
  {
    "Date": "2020-06",
    "data": [
      {
        "id": "cf44e27f-2111-462d-b3bd-420a193745b8",
        "Date": "2020-06-02T00:00:00.000Z",
        "transactionId": "5",
        "transactionType": "Payment",
        "amount": 1000
      }
    ]
  }
]
Here there is key Date and there are two values for the same date key. Now I want if Date is same then data array record should merged.
So i expect output as
[
  {
    "Date": "2020-07",
    "data": [
      {
        "id": "35ebd073-600c-4be4-a750-41c4be5ed24a",
        "Date": "2020-07-03T00:00:00.000Z",
        "transactionId": "13",
        "transactionType": "Payment",
        "amount": 1500
      },
      {
        "id": "4e126519-e27b-4e82-bb81-689c7dc63c9b",
        "Date": "2020-07-02T00:00:00.000Z",
        "transactionId": "4",
        "transactionType": "Payment",
        "amount": 1000
      }
    ]
  },
  {
    "Date": "2020-06",
    "data": [
      {
        "id": "646d6497-9dea-4f27-896e-a45d97a252ea",
        "Date": "2020-06-04T00:00:00.000Z",
        "transactionId": "14",
        "transactionType": "Payment",
        "amount": 1500
      },
       {
        "id": "cf44e27f-2111-462d-b3bd-420a193745b8",
        "Date": "2020-06-02T00:00:00.000Z",
        "transactionId": "5",
        "transactionType": "Payment",
        "amount": 1000
      }
    ]
  }
]
Please tell me best-optimized way of doing it ?
 
     
     
    