Skip to content

Instantly share code, notes, and snippets.

@pablogrs
Created November 21, 2019 13:49
Show Gist options
  • Save pablogrs/a37ea297eb8335d604ffd19acf248d77 to your computer and use it in GitHub Desktop.
Save pablogrs/a37ea297eb8335d604ffd19acf248d77 to your computer and use it in GitHub Desktop.
Get element in nested map
// _mapToSearch is a map of maps
// path is something like "commit.author.name"
String getNestedElementInMap(Map _mapToSearch, String path){
def elements = path.split('\\.')
def currentValue = _mapToSearch
println(elements)
for(key in elements){
currentValue = currentValue[key]
}
return currentValue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment