cancel
Showing results for 
Search instead for 
Did you mean: 

Merging two arrays and sending it via Email

aditya_gupta41
Contributor

Below are the input and the output of the data i require:
INPUT

[
  {
    "group": [
      {
        "Response": {
          "IT_DATA": [
            {
              "LID": "LOA-1",
              "LVOL": 2150000.0,
              "LGM": 0.15,
              "LRCW": 0.0077,
              "LPRO": -0.028,
              "LRCWOW": 0.0081,
              "LLCUR": "EUR"
            }
          ],
          "ET_LOG": [
            {
              "MSGNUMBER": 1,
              "MSGTY": "S",
              "MSGV1": "LoA ID successfully updated.",
              "MSGV2": "ABCDEFG",
              "MSGV3": "",
              "MSGV4": "",
              "TIME_STMP": 123123
            }
          ]
        }
      },
      {
        "Response": {
          "IT_DATA": [
            {
              "LID": "LOA-2",
              "LVOL": 740000.0,
              "LGM": 0.286,
              "LRCW": 0.01,
              "LPRO": 0.121,
              "LRCWOW": 0.03,
              "LLCUR": "EUR"
            }
          ],
          "ET_LOG": [
            {
              "MSGNUMBER": 1,
              "MSGTY": "S",
              "MSGV1": "LoA ID successfully updated.",
              "MSGV2": "ZYXM",
              "MSGV3": "",
              "MSGV4": "",
              "TIME_STMP": 098098
            }
          ]
        }
      }
  ]
  }
  ]

OUTPUT

[
  {
              "LID": "LOA-1",
              "LVOL": 2150000.0,
              "LGM": 0.15,
              "LRCW": 0.0077,
              "LPRO": -0.028,
              "LRCWOW": 0.0081,
              "LLCUR": "EUR",
			  "MSGNUMBER": 1,
              "MSGTY": "S",
              "MSGV1": "LoA ID successfully updated.",
              "MSGV2": "ABCDEFG",
              "MSGV3": "",
              "MSGV4": "",
              "TIME_STMP": 123123
    },
		  
    {
              "LID": "LOA-2",
              "LVOL": 740000.0,
              "LGM": 0.286,
              "LRCW": 0.01,
              "LPRO": 0.121,
              "LRCWOW": 0.03,
              "LLCUR": "EUR",
			  "MSGNUMBER": 1,
              "MSGTY": "S",
              "MSGV1": "LoA ID successfully updated.",
              "MSGV2": "ZYXM",
              "MSGV3": "",
              "MSGV4": "",
              "TIME_STMP": 098098
    }     
  ]

This output will be later used to be put in a HTML table format and to sent via email.

image

Can anyone please help me out here. Thanks in advance.

2 REPLIES 2

bojanvelevski
Valued Contributor

Hey @aditya.gupta41,

Use the following expression in a mapper, and you’ll receive the output you need:

$group.map(x=>x.Response.values().reduce((acc,curr)=> acc.concat(curr),[]).reduce((acc,curr)=> acc.extend(curr), {}))

Regards,
Bojan

aditya_gupta41
Contributor

This worked for me. Thanks