2. In this tutorial we will be creating an easy csv to json converter using mule esb.
Let’s begin creating a simple flow with file reader component, in order to trigger the
transformation:
Now let’s create a csv file under the folder src/main/resources/input named test.csv in
this way:
3. Now it’s time to configure the File component to read the csv file just created:
Let’s recall that Polling Frequency is the
interval of polling the input path (in
millliseconds)
Now we are ready to put the transformation using the DataWeave component
Click on the «Edit sample data» button and paste the content
of the csv file in order to see the preview, not before having set
the output to application/json and made the payload the
output:
4. Finally, put an Object to String transformer and a Logger to see the results:
[[db_test].converter_testFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: [
{
"Billing Street": "111 Boulevard Hausmann",
"Billing City": "Paris",
"Billing Country": "France",
"Billing State": "",
"Name": "Dog Park Industries",
"BillingPostalCode": "75008"
},
{
"Billing Street": "400 South St",
"Billing City": "San Francisco",
"Billing Country": "USA",
"Billing State": "CA",
"Name": "Iguana Park Industries",
"BillingPostalCode": "91156"
},
{
"Billing Street": "777 North St",
"Billing City": "San Francisco",
"Billing Country": "USA",
"Billing State": "CA",
"Name": "Cat Park Industries",
"BillingPostalCode": "91156"
}
]
Enjoy with the Mule!