I need to format an incoming payload JSON to a certain manner. The sample payload JSON is given below.
[
{
"value": {
"States": [
{
"Name": "New South Wales",
"Code": "NSW"
}
]
}
},
{
"value": {
"States": [
{
"Name": "Western Australia",
"Code": "WA"
}
]
}
}
]
The output that I'm trying to get to is given below:
[
{
"SystemCode": "STATE",
"Name": "StateName",
"Code": "NSW"
},
{
"SystemCode": "STATE",
"Name": "StateName",
"Code": "WA"
}
]
As you can see above, in the output, SystemCode and Name will remain constant, whereas the Code value will change as per the incoming payload. Once the required output is generated, I need to store the same as a JSON in a session variable. How can I achieve this in Mule dataweave 1.0 Please note that I can receive multiple arrays as payload with different codes. Thanks in advance.