Mule JSON对象转换为带回车符的字符串

Mule JSON对象转换为带回车符的字符串,mule,tostring,dataweave,text-indent,Mule,Tostring,Dataweave,Text Indent,在我的流程中,我读取并运行()一个JSON对象数组。我使用APPEND类型在同一文件中插入每个对象 我想将每个JSON和indent存储为false(JSON的一行)和一个回车,如下示例: {"hello:"world1"} {"hello:"world2"} {"hello:"world3"} 我用这个: %dw 2.0 output application/json indent=false --- payload ++ '\r' 但它返回一个关于无法将对象强制为字符串的错误

在我的流程中,我读取并运行()一个JSON对象数组。我使用APPEND类型在同一文件中插入每个对象

我想将每个
JSON
indent
存储为false(JSON的一行)和一个
回车
,如下示例:

{"hello:"world1"}

{"hello:"world2"}

{"hello:"world3"}
我用这个:

%dw 2.0
 output application/json indent=false
 ---
 payload ++ '\r'
但它返回一个关于无法将对象强制为字符串的错误。
如何解决这个问题?

从技术上讲,application/json是一个对象,而不是字符串。所以不能直接连接

这对我来说很有用,可以得到想要的结果:

%dw 2.0
output application/java
---
write(payload, "application/json", {"indent":false}) as String ++ '\r'
write as json首先使用writer属性删除缩进,然后转换为字符串,连接并输出为字符串application/java