1
votes

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"
  }
]
1

1 Answers

2
votes

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"