khaja aminul hussain
khaja aminul hussain

Reputation: 97

How to get a value from an array in Mule 4

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

Answers (2)

Sébastien Colas
Sébastien Colas

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

utechtzs
utechtzs

Reputation: 1023

This dataweave:

%dw 2.0
output application/json
---
payload..value[0]

will produce:

savings

Upvotes: 2

Related Questions