Created
November 21, 2019 13:49
-
-
Save pablogrs/a37ea297eb8335d604ffd19acf248d77 to your computer and use it in GitHub Desktop.
Get element in nested map
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
// _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