0
votes

I have a CSV file which sends records in the following format:

John,Smith,presentation|researcher|developer,[email protected],07891234567

I need to take each record and map them to a list of the following JSON object:

[
   {
      "firstName": "John",
      "surname": "Smith",
      "skills": 
      [
         "presentation",
         "developer",
         "researcher"
      ]
      "email": "[email protected]",
      "phone": "07891234567"
   }
[

My problem is that how do you split the address text string and populate the address object along with the other fields using Dataweave and the Transform message component in Mule 3.8.1?

Thanks

1

1 Answers

2
votes

You can use the splitBy to get what you are wanting.

%dw 1.0
%input payload application/csv
%output application/json
---
payload map {
  firstname: $.firstname,
  lastname: $.lastname,
  skills: $.skills splitBy ('|'),
  email: $.email,
  phone: $.phone
}