97008 48403
+91 40-27177600

Blog

Converting list hashmap into Array using Dataweave in Mule ESB

single-blog

From the technical center of excellence of Massil Technologies, our technology leaders make 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 talks about converting list hashmap into Array using Dataweave 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.

Converting list hashmap into Array using Dataweave in Mule ESB:

The Given list can be transformed to array as shown below

List is like : [{customerId=”123″},{customerId=”456″},{customerId=”786″}]

Converted Array is like : [123,456,786]

Step 1:

Create a Mule ESB Project and add HTTP listener connector to Mule Flow and connect a set payload to the flow as shown below:

Step 2:

Add JSON to object earlier the setpayload to transform the JSON payload to object format in json to object Return class as java.lang.Object.

Step 3:

Attach an object to JSON subsequently the payload and add Transform Message to the flow to convert the hash map list to an array. Write in transform message to convert list to array is as below:

—————————————————————————————————————–

%dw 1.0

%output application/java

payload.customerId map $ as :number


Step 4:

Enhance setpayload and write in payload as #[payload] and add an object to json at the conclusion of the flow and run the project

Output:

Given input as: [{“customerId”:”123″},{“customerId”:”456″},{“customerId”:”786″}]

OutPut: [123, 456, 786]

Hence, we have gone through the step by step process to depict the way Massil Technologies team has addressed the client need. 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