简体   繁体   中英

JSON file not formatted if object to json transformer is used

In data weave, the output format is application/java. Transforming the data weave output payload to JSON using object to Json transformer and writing to file. The Json content in the file is not formatted.

If i change the output format to application/json and removed the object to Json transformer and write to file, the Json content in the file is formatted.

I have the need to keep the output format in data weave to application/java. How can i get formatted Json content in the file?

You could do this by using 2 dataweave components. Keep the one you currently have that outputs the payload as application/java then add a second one which outputs as application/json but set the target to be a variable instead of the payload (click the arrow next to payload and click Add New Target).

You could then use the variable to write the contents of the file and continue using the payload that will be kept as application/java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM