Skip to content

Instantly share code, notes, and snippets.

@emoran
Created February 10, 2022 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emoran/055a8b509044c899d9fdcddbfe66ff41 to your computer and use it in GitHub Desktop.
Save emoran/055a8b509044c899d9fdcddbfe66ff41 to your computer and use it in GitHub Desktop.
%dw 2.0
import try, fail from dw::Runtime
output application/java
fun isDate(value: Any): Boolean = try(() -> value as Date).success
fun getDate(value: Any): Date | Null | Any = ( if ( isDate(value) ) value
as Date as String else value )
---
(payload map (item,index) ->{
(item mapObject ((value, key, index) -> {
(key):(getDate(value))
} ))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment