Created
September 28, 2018 18:39
-
-
Save forgo/310d614f49e183308d653f90ebff6d2f to your computer and use it in GitHub Desktop.
Debug Groovy Map Key Hierarchy
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
| def mapStructure(Map map, int layer = 0) { | |
| map.each { key, value -> | |
| println "${('\t' * layer) + key}: ${layer.toString()}" | |
| if(value.getClass() == LinkedHashMap.class) { | |
| mapStructure((Map)value, layer+1) | |
| } | |
| } | |
| } | |
| // Example usage: | |
| /* | |
| Map map = [ | |
| input: [ | |
| method: "POST", | |
| host: "hostname", | |
| requestURL: "https://www.whatever.com" | |
| ], | |
| content: "<xml>whatever</xml>", | |
| id: [ source1: '123456' ] | |
| ] | |
| mapStructure(map) | |
| */ | |
| // Example output: | |
| /* | |
| input: | |
| method: | |
| host: | |
| requestURL: | |
| content: | |
| id: | |
| source1: | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment