Skip to content

Instantly share code, notes, and snippets.

@robhinds
Created January 22, 2014 21:27
Show Gist options
  • Save robhinds/8567658 to your computer and use it in GitHub Desktop.
Save robhinds/8567658 to your computer and use it in GitHub Desktop.
//This code iterates a nested Map/List structure and converts any Date objects it finds into
// String equivalents.
//def data = [:] - data is some complex nested Map/List data structure
UnwelcomeVisitor.traverse( data, [
visitMap: { key, value ->
if ( value instanceof Date ) value = value.toString()
value
},
visitList: { entry ->
if ( entry instanceof Date ) entry = entry.toString()
entry
}
] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment