mule-user mule-user - 1 year ago 113
JSON Question

Json to XML conversion in mule data weave

I have the following json data and I want to convert to xml as it is.
Is there a way simplest way to do it in mule data weave

"Header": {
"Date": "20160721145839",
"UTC_Time": null,
"TransactionDateTime": "20160721145839",
"EventType": "Test",
"PlaceOfEvent": "AUD",
"RefNo": "SHPL123123",
"SenderUserName": "APINAR"
"Body": {
"Number": "ZZZZ",

"vfgt": 2000,
"Decwt": 0,
"Status": "F",
"Category": "E",
"AdditionalData": {
"MethodOfWeightCalculation": "SM2",
"wtData": {
"Country": "AU"
"Declarant": {
"DeclarantPhone": "55555555"
"EDISignature": "x"

When I try something like below its giving me error in mule

%dw 1.0
%output application/xml skipNullOn="everywhere"

Answer Source

You require root element for xml transformation. There is no problem with json input. Following works fine.

%dw 1.0
%output application/xml
root : payload

Hope this helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download