简体   繁体   中英

Mule dataweave transformation

I have below json as my input payload and I want to fetch groupvalue where groupname is b. How to do this in dataweave?

[
  {
    "groupName": "a",
    "groupvalue": "1234"
  },
  {
    "groupName": "b",
    "groupvalue": "7890"
  }
]

If you are absolutely sure there is only one element in the array with groupName equal to "b":

%dw 2.0
output application/json
---
(payload filter ($.groupName == "b") map ( $.groupvalue)) [0]

With your input I get the following output:

"7890"

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