97008 48403
+91 40-27177600

Blog

Converting JSON file into Excel in Mule ESB

single-blog

From the technical center of excellence of Massil Technologies, our technology leader Srini makes it easy to understand the complex situations you come across in Mule ESB from the experience of Massil Technologies to have countered them in their experience of working on client projects in real time. This blog addresses how to convert JSON file into excel file in  Mule ESB. This blog is a part of series of blogs being authored and published by Massil Technologies for the benefit of the IT community globally.

What is JSON?

JavaScript Object Notation or JSON is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute-value pairs and array data types.

What is Excel?

Microsoft Excel is a spreadsheet developed by Microsoft for Windows, macOS, Android, and iOS. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications.

Converting JSON file into Microsoft Excel file in Mule ESB:

In Mule ESB the flow for converting JSON File to Microsoft Excel is as follows:

The XML code mentioned below is used to make the conversion:

<flow name=“muleDataweaveExcelOutputFlow”>

<http:listener config-ref=“HTTP_Listener_Configuration” path=“/ExcelOutput” allowedMethods=“POST” doc:name=“HTTP”/>

<dw:transform-message doc:name=“Transform Message”>

<dw:set-payload><![CDATA[%dw 1.0

%output application/csv header=true

{

new order:{

newItem:”Book”,

newTitle:”$(payload.title)”,

newdetails:”By $(payload.author) ($(payload.year))”

}

}]]></dw:set-payload>

</dw:transform-message>

</flow>

Dataweave Script coding is also used in making the conversion:

%dw 1.0

%output application/csv header=true

{

new order:{

newItem:”Book”,

newTitle:”$(payload.title)”,

newdetails:”By $(payload.author) ($(payload.year))”

}

}

To run the above conversion, the input to JSON file is:

{

“title”:”java edition”,

“author”:”ramson”,

“year” : 2010,

“pages”: 100

}

The output in excel sheet will be as follows:

newItem,newTitle,new details

Book, java edition, By ramson (2010)

Hope this article from Massil Technologies was useful for you. If you have any further queries on this topic, please reach out to info@massil.tech.

Leave a Reply

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

Contact Us

Get in touch with us

Scroll to top