Skip to content

JSON to XML in DataWeave (DW 2.0) – Study Notes

DataWeave – Easy transformations

The DataWeave makes it easy to transform the payload into different types. But there are also some catches which you need to be aware of. In this short post, I will present how can you transform a JSON payload to XML.

XML Root Element

Some types of transformations can be applied directly, only by changing the type declaration (application/json, application/java). This is not the case for application/xml. If you have a JSON input payload you will have to add the XML root element to the DataWeave transformation.

%dw 2.0
output application/xml

---
yourRoot:
  firstParam: "Your Custom Param"

XML allows only one root element.

Photo by Scott Webb on Unsplash

1 thought on “JSON to XML in DataWeave (DW 2.0) – Study Notes”

Leave a Reply

Your email address will not be published. Required fields are marked *