I have the following DW 2.0 function for trimming white space on any string values in a JSON payload:
fun whiteSpaceTrimmer(item) = item match {
case is Array -> $ map whiteSpaceTrimmer($)
case is Object -> $ mapObject {
($$): $ match {
case is String -> trim($)
case is Object -> whiteSpaceTrimmer($)
case is Array -> $ map whiteSpaceTrimmer($)
else -> $
}
}
case is String -> trim($)
else -> $
}
Since it is recursive and I am not sure how deep of a nested structure it could handle before throwing an exception. Is there a limit on how many nested elements I can pass into this function? And if so is there a better approach?