1

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..

utechtzs
  • 1,013
  • 5
  • 12

2 Answers2

2

This dataweave:

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

will produce:

savings

utechtzs
  • 1,013
  • 5
  • 12
2

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 $