%dw 2.0
import * from dw::core::Strings
output application/json
---
{ balance: ("\$234" mapString if (isNumeric($)) "~" else $) }
DataWeave
mapString
mapString(@StreamCapable text: String, mapper: (character: String, index: Number) -> String): String
Applies an expression to every character of a string.
Introduced in DataWeave version 2.4.0.
Parameters
Name | Description |
---|---|
|
The string to map. |
|
Expression that applies to each character ( |
Example
This example redacts sensitive data from a string.
Source
Output
{
"balance": "$~~~"
}
Json
mapString(@StreamCapable text: Null, mapper: (character: Nothing, index: Nothing) -> Any): Null
Helper function that enables mapString
to work with a null
value.
Introduced in DataWeave version 2.4.0.