简体   繁体   中英

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 ?

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM