0

I am working on mule 4. I want to use the key defined above in transformer below. for example, my transformer is

%dw 2.0
output application/json
---
{
    name : usama,
    age : 24,
    value: age
}

here in the third key i.e. "data" I want to use the value of "age" key.

Can anyone help?

the output should be as defined below

{
    name : usama,
    age : 24,
    value: 24
}
utechtzs
  • 1,013
  • 5
  • 12
M.Usama
  • 3
  • 2
  • 1
    the top is not valid dataweave as 'usama' and 'age' aren't defined as variables or functions. If they're strings, please add quotes around them. – utechtzs Aug 22 '19 at 12:48

1 Answers1

4

Hi you can either define a global variable and reference it in both places or use a do block

%dw 2.0
output application/json
var age = 24
---
{
    name : "usama",
    age : age,
    value: age
}
machaval
  • 4,969
  • 14
  • 20