title: Reading json Payload as part of a CSV file in dataweave
body: <p>I have a web service which exports a CSV file which has one of the columns as a JSON payload. After the execution of the web service, I store the values in a local variable for transformation. Every time when I read the values from that column I am missing the values and only "}" is returned. Not sure why this is happening. I want to preserve the JSON payload as is and persist to a file after some processing. Please advise</p>
  
  <p>I am using the code below to get the value of the attribute column and it always returns a "}". The rest of the contents are ignored</p>
  
  <pre><code>CSV Fragment
  -------------
   id,name,attributes
   1,name1,{"Choice Number":"0","Campaign Run Id":"234"}
   2,name2,{"Choice Number":"1","Campaign Run Id":"235"}
   3,name3,{"Choice Number":"2","Campaign Run Id":"236"}
   4,name4,{"Choice Number":"3","Campaign Run Id":"236"}
  
  
  Code
  ----
   %dw 1.0
   %output application/java
   ---
   flowVars.activityData map ((actData) -&gt; {
        "playerId": actData.id,
        "name": actData.name,
        "attributes": actData.attributes
    })
  
  </code></pre>
  
  <p>I was expecting that the full JSON payload from the attributes column will be returned and that is not the case. One thing that I noticed here is that there is no escaping of characters in the JSON payload in the input. But I don't have any control on that as well. How do I extract the information from the attribute column in this case</p>
  
  <hr>
  
  <p>Since I cannot share the whole project, created a sample project and using the inputs from @machaval with http object receiving the csv file. Marked the mimetype as text/csv and sending the payload</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
      xmlns:spring="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
  http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
  http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
  http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
  http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
  http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd"&gt;
      &lt;http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/&gt;
      &lt;flow name="CSVFlow"&gt;
          &lt;http:listener config-ref="HTTP_Listener_Configuration" path="/process" doc:name="HTTP"/&gt;
          &lt;object-to-string-transformer doc:name="Object to String"/&gt;
          &lt;dw:transform-message doc:name="Transform Message"&gt;
              &lt;dw:set-payload&gt;&lt;![CDATA[%dw 1.0
  %output application/json
  ---
  //First remove the header
  (payload splitBy "\n")[1 to -1] 
      map ((item, index) -&gt; using(commas = item find ",")             
          {
              id: item[0 to commas[0] - 1],
              name: item[commas[0] + 1 to commas[1] - 1],
              attributes: item[commas[1] + 1 to -1]
          }
      )]]&gt;&lt;/dw:set-payload&gt;
          &lt;/dw:transform-message&gt;
      &lt;/flow&gt;
  
  &lt;/mule&gt;
  </code></pre>