2

Exisiting Json { a:1, b:2 }

Add the field c:3

Final Output expected { a:1, b:2, c:3 }

user3440239
  • 78
  • 1
  • 5

2 Answers2

2
%dw 2.0
output application/json

---

{ a:1, b:2 } ++ {c: 3}

Sample Output:

{
  "a": 1,
  "b": 2,
  "c": 3
}
machaval
  • 4,969
  • 14
  • 20
Manish Yadav
  • 210
  • 5
  • 8
1

You can directly keep payload as it is and add the new JSON field as below:

payload ++ {c:3}

output:
{ 
 a:1,
 b:2, 
 c:3 
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129