title: Mule Dataweave Map with SplitBy
body: <p>I have a Mule flow, which converts CSV data to XML. There is a field which I need to map and split by a character. I am receiving an error which states </p>
  
  <pre><code>Cannot coerce a :array to a :object.
  </code></pre>
  
  <p>Here is the results I need to achieve:</p>
  
  <pre><code>&lt;Dataset&gt;
  &lt;ListingName&gt; Name Here &lt;/ListingName&gt;
  &lt;Description&gt; Description Here &lt;/Description&gt;
  &lt;Price&gt;110,000&lt;/Price&gt;
  &lt;SerialSet&gt;
      &lt;Hours&gt;1255&lt;/Hours&gt;
      &lt;Serial&gt;9110136&lt;/Serial&gt;
  &lt;/SerialSet&gt;
  &lt;Dealer&gt; Name Here &lt;/Dealer&gt;
  &lt;DealerAddress&gt;Continental, Ohio 45831&lt;/DealerAddress&gt;
  &lt;Date&gt;2018-10-24&lt;/Date&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the flow I am using:</p>
  
  <pre><code>    &lt;dw:transform-message doc:name="Transform Message"&gt;
      &lt;dw:input-payload mimeType="application/csv"/&gt;
          &lt;dw:set-payload&gt;&lt;![CDATA[%dw 1.0
          %output application/xml
          ---
          {
          Tractor: {
             (payload map ((payload01 , indexOfPayload01) -&gt; {
             Dataset: {
               ListingName: payload01.ListingName,
               Description: payload01.Description,
               Price: payload01.Price,
               SerialSet: (payload01.Serial replace /[{}]/ with "" splitBy ";")  map using (data = $ splitBy ":")   {
                  (data[0]) : data[1]
               },
               Dealer: payload01.DealerName,
               DealerAddress: payload01.DealerAddress,
               Date: now as :string {format: "yyyy-MM-dd"}
               }
            }))
          }
          }
          ]]&gt;&lt;/dw:set-payload&gt;
  </code></pre>
  
  <p>However my flow kicks back the following: </p>
  
  <pre><code>Cannot coerce a :array to a :object.
  </code></pre>
  
  <p>Here is what the raw data looks like that I am trying to map for the SerialSet field:</p>
  
  <pre><code> &lt;SerialSet&gt;Hours: 3280; Serial Number: A7809001946; Condition: Used; Stock Number: 6465&lt;/SerialSet&gt;
  </code></pre>
  
  <p>Should be a node for each item based on the key -> value pairs, in this instance it should look like:</p>
  
  <pre><code>&lt;SerialSet&gt;
    &lt;Hours&gt;3280&lt;/Hours&gt; 
    &lt;Serial Number&gt;A7809001946&lt;/Serial Number&gt;
    &lt;Condition&gt;Used&lt;/Condition&gt; 
    &lt;Stock Number&gt;6465&lt;/Stock Number&gt;
  &lt;/SerialSet&gt;
  </code></pre>