import groovy.util.Eval def compareArrays(def first, def path = '', def second) { if (first instanceof java.util.LinkedHashMap) { first.each { index, value -> if ( index.indexOf('-') > 0 ) { index = index.inspect() } if ( value instanceof java.util.LinkedHashMap ) { def newPath = path ? path + "." + index : index compareArrays(value, newPath, second) } else { def newPath = path ? path + "." + index : index def secondValue = Eval.me("array", second, "array.$newPath") if (secondValue == null ) { println "ERROR: Missing path $newPath in second array!" } else if ( value != secondValue ) { println "ERROR: Different value for path: $newPath, '$value != '$secondValue" } } } } }