Search code examples
dataweavemulesoftanypoint-studiomule4

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

  • Are you looking to achieve something like below?

    %dw 2.0
    output application/json
    
    var a = "$(payload[0].Name)"
    ---
    a
    

    otuput enter image description here