Reputation: 97
I wanted to get a value in an array without using absolute array positioning. Here is my json payload.
{
"xyz":{
"abc":[
{
"account":[
{
"value":"savings"
}
]
}
]
}
}
How to get the value savings using Data Weave..
Upvotes: 1
Views: 4263
Reputation: 424
You can also do that. I supposed you don't want to use at all indexes and that there is only one key value in the payload:
%dw 2.0
output application/json
var data = {"xyz": {"abc":["account":[{"value":"savings"}]]}}
---
data..value reduce $
Upvotes: 2
Reputation: 1023
This dataweave:
%dw 2.0
output application/json
---
payload..value[0]
will produce:
savings
Upvotes: 2