Reputation: 458
In Mule 4 I am reading a clob column(data is in JSON) from Oracle DB Table and tring to transform to JSON. I am getting a String response with all the escape characters and hence unable to parse JSON. My transformation is as below
<ee:transform doc:name="Transform Message" doc:id="12c74f4a-56d7-4d9a-9cb1-1348c93edfe2" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload
]]></ee:set-payload>
</ee:message>
</ee:transform>
The output I am getting is as below
{"EXPENSE_REPORT_DETAILS": "{\n \"UserLoginID\": \"xyz\",\n \"EmployeeName\": \"abcd\"}}
Is there any way I can get back JSON instead of String without all the escape characters so I can parse. Even Java would be fine as what I need is to get payload.EXPENSE_REPORT_DETAILS.UserLoginID
etc.
Upvotes: 0
Views: 569
Reputation: 3261
CLOB is just a large string. You just need to look for ways to convert a string to JSON.
Because your string is in payload.EXPENSE_REPORT_DETAILS
you need to use read function and pass it as the first param
%dw 2.0
output application/json
---
{
EXPENSE_REPORT_DETAILS: read(payload.EXPENSE_REPORT_DETAILS,"application/json")
}
Upvotes: 3