简体   繁体   中英

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. 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. That's how JSON works, it is not a Mule issue.

Here single slash treated internally as double slash. Try the dataweave expression like below

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

在此处输入图片说明

Hope it helps

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