Converts JSON to a string and writes to a file

advertisements

How can i convert a JSON object to String and write to a file? The output type in data weave is application/java


If the output in DataWeave is set to application/json just sending the payload to a file transport should write the payload to the file.

Example:

        <dw:transform-message doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
payload
]]></dw:set-payload>
        </dw:transform-message>
        <file:outbound-endpoint path="/tmp" outputPattern="jsonoutput"   responseTimeout="10000" doc:name="File"/>