Sri Rockz
Sri Rockz

Reputation: 85

How do you use variable as key in Dataweave

output application/json

var name = vars.uname
---
{
    
   vars.name: name, //-----> Here i am not able too retreive variable as key
   
   description: payload.text
    
    }

for reference

Upvotes: 2

Views: 2210

Answers (1)

machaval
machaval

Reputation: 5059

You need to use parenthesis in the key to specify that is an expression.

output application/json

var name = vars.uname
---
{
    
   (vars.name): name, //-----> Here i am not able too retreive variable as key
   
   description: payload.text
    
}

Upvotes: 5

Related Questions