Search code examples
muledataweaveanypoint-studio

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


Solution

  • 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
        
    }