Infinity
Infinity

Reputation: 526

Unable to Set flowVars as Key in Json Request

I am trying to set up the key value for json from the flowVar. Its not working in dataweave 2.0. I might be missing something (syntax). I have a variable test with value. Dataweave code looks like below.

%dw 2.0
output application/json
---
{
    vars.test: "hi"
}

Upvotes: 0

Views: 90

Answers (1)

aled
aled

Reputation: 25837

You need to use parenthesis around the key if it is dynamic:

%dw 2.0
output application/json
---
{
    (vars.test): "hi"
}

Upvotes: 3

Related Questions