'how to consider string as a value in Dataweave

We have a payload:

payload = [
  {
    "Name": "XYZ",
    "DOB": "2025-03-28",
    "Class": "N/A"
  }
]

DW:
%dw 2.0
output application/json

var a = "payload.Name"
---
a

The dw is giving output as string "payload.Name". Any inputs how to retrieve the value of payload.Name using the var a? i.e. XYZ in this case



Solution 1:[1]

I would just use payload[0].Name or payload[0].Name as String in case the name is not a String that is not your case

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 machaval