Thanumoorthy
Thanumoorthy

Reputation: 13

Convert list of JSON Object to single list on Mule DataWeave

Input:-

[
  {
    "appName": "helloworld-1"
  },
  {
    "appName": "helloworld-2"
  }
]

Expected Output

{
"appList": [ "helloworld-1" , "helloworld-2" ]
}

Can anyone guide me for data weave script for this ?

Upvotes: 0

Views: 1786

Answers (1)

Angelo Sandaga
Angelo Sandaga

Reputation: 126

According to the DataWeave Documentation, you can apply the multi value selector. Multi value selector returns an array with all the values whose key matches the expression.

%dw 1.0
%output application/json
---
{
    appList : payload.*appName
}

Upvotes: 0

Related Questions