The Powerful Dataweave –
Lab1
Srilatha Kante
Introduction
• Dataweave is a language used to transform the data
• Dataweave language is a powerful template engine
• Dataweave can transform the data to and from any kind of data
• JSON
• XML
• Pojos
• Maps
• CSV
• Etc.,
JSON to XML
• Create the sample JSON data
• Use the JSON data in Set Metadata in input section
• {
“description": “This Dataweave language is very powerful and we are
seeing JSON to XML transformation",
“type": “JSON to XML",
“date": “26-07-2016”
}
Transform Message in mule flow
Set Sample metadata in input
Write the dataweave script as
%dw 1.0
%output application/xml
---
{
order:{
type: "Transformation",
notes: payload.description,
details: payload.type
}
}
Check the output using Preview
Output as XML
• Click on Preview
• Check the output as,
<?xml version='1.0' encoding='windows-1252'?>
<order>
<type>Transformation</type>
<notes>This Dataweave language is very powerful and we are seeing
JSON to XML transformation</notes>
<details>By JSON to XML</details>
</order>

Dataweave

  • 1.
    The Powerful Dataweave– Lab1 Srilatha Kante
  • 2.
    Introduction • Dataweave isa language used to transform the data • Dataweave language is a powerful template engine • Dataweave can transform the data to and from any kind of data • JSON • XML • Pojos • Maps • CSV • Etc.,
  • 3.
    JSON to XML •Create the sample JSON data • Use the JSON data in Set Metadata in input section • { “description": “This Dataweave language is very powerful and we are seeing JSON to XML transformation", “type": “JSON to XML", “date": “26-07-2016” }
  • 4.
  • 5.
  • 6.
    Write the dataweavescript as %dw 1.0 %output application/xml --- { order:{ type: "Transformation", notes: payload.description, details: payload.type } }
  • 7.
    Check the outputusing Preview
  • 8.
    Output as XML •Click on Preview • Check the output as, <?xml version='1.0' encoding='windows-1252'?> <order> <type>Transformation</type> <notes>This Dataweave language is very powerful and we are seeing JSON to XML transformation</notes> <details>By JSON to XML</details> </order>