Descendants Selector

 

Works on arrays and objects and to retrieves the values of all matching key-value pairs in the sub-tree under the selected context regardless of the hierarchical structure of the fields. Let’s see how Descendants Selector works.

The .. selector acts on arrays and objects

Input Payload

{
  "employees": {
    "employee": {
      "emp_name": "ram",
      "address": {
        "street": {
          "emp_name": "john",
          "employeenumber": 1234
        },
        "area": {
          "zip": "110032",
          "emp_name": "shyam"
        }
      }
    }
  }
}

Dataweave expression:

%dw 2.0
output application/json
---
{
  emp_name: payload.employees..emp_name
}

Output

{
  "emp_name": [
    "ram",
    "john",
    "shyam"
  ]
}
  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments