简体   繁体   English

在 mule 4 dataweave 转换中删除反斜杠

[英]removing backslashes in mule 4 dataweave transformation

I am fetching data from SQL Server Database and transforming it into JSON in Mule 4. My input has a single backslash and converted to double backslashes.我正在从 SQL Server 数据库中获取数据并将其转换为 Mule 4 中的 JSON。我的输入有一个单反斜杠并转换为双反斜杠。 I only need a single backslash in my output.我的输出中只需要一个反斜杠。

Input example:输入示例:

abchd\kdgf

Output is:输出是:

"abchd\\kdgf"

It should be:它应该是:

"abchd\kdgf"

Anyone can help with this data weave transformation?任何人都可以帮助进行这种数据编织转换吗?

In JSON strings the backslash character is the escape character, and has to be escaped itself to represent a single backlash.在 JSON 字符串中,反斜杠字符是转义字符,必须对其本身进行转义以表示单个反斜杠。 That's how JSON works, it is not a Mule issue.这就是 JSON 的工作原理,这不是 Mule 的问题。

Here single slash treated internally as double slash.这里单斜线在内部被视为双斜线。 Try the dataweave expression like below试试下面的 dataweave 表达式

payload replace /([\\])/ with ("")

在此处输入图片说明

Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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