Matching of JSON object and Array List and filtering output of matched values

Hi,

I have an Array List telling me the fields in which changes have occurred.

In the eg. below,
I want the fields in changes to be matched with fields in temp and provide output such that only the matched fields appear in output.

Input:

[
  {
    "temp": [
      {
        "displayGSID": "2519",
        "legalCompanyName": "12 FEB",
        "website": "abc@zyx.com",
        "taxidAndWxformRequired": "NO",
        "taxidFormat": "Othr",
        "companyTypeFix": "SUPPLIER",
        "fields": {
          "field": [
            {
              "id": "EMAILID",
              "value": "demo.Kumar@zyx.com"
            },
            {
              "id": "TRANSACTION_CURRENCY",
              "value": "INR"
            },
            {
              "id": "VENDOR_TYPE",
              "value": "4"
            }
          ]
        }
      }
    ],
    "changes": [
      "website",
      "taxid",
      "fields/field/id=MAILID"
    ]
  }
]

Desired Output:
{
“companyDetails”:
{
“website”: “abc@zyx.com”,
“taxid”: “”,
“fields”: {
“field”: [
{
“id”: “EMAILID”,
“value”: “demo.Kumar@zyx.com
}
]
}
}