Stanislav Ivanov
Stanislav Ivanov

Reputation: 443

Escape character in DataWeave string

We are getting a value from a DB that contains a backslash (\). After going through DataWeave, we get 2 backslashes. Here it is how it looks:

enter image description here

How can we have only one backslash in the end? Can we use the replace function somehow? I tried and could not make it work.

Upvotes: 1

Views: 10894

Answers (2)

Ljk
Ljk

Reputation: 11

You could try to put in an escape character of your choice

Eg: %output application/csv escape = " "

This should ideally replace "/" with " ".

Hope this helps.

Upvotes: 1

Nico Balestra
Nico Balestra

Reputation: 266

I believe the reason why you see two backslashes is because backslash is a reserved character (see JSON spec) therefore DataWeave is automatically escaping the backslash, which is necessary so not to have your DB value corrupted.

In my opinion the double backslash is not a problem. You should get the right content upon consuming the JSON object.

Upvotes: 3

Related Questions