Created
January 22, 2014 21:27
-
-
Save robhinds/8567658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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