def obj1 = """{
  "A" : "Test1",
  "B" : "Test2"
}"""

def obj2 = """{
  "A" : "Test1a",
  "B" : "Test2b"
}"""

def getJsonKeys = { jsonString ->
   def json = new groovy.json.JsonSlurper().parseText(jsonString)
   json.keySet()
}

def obj1Keys = getJsonKeys(obj1)
def obj2Keys = getJsonKeys(obj2)
println "Keys from json1 : ${obj1Keys}"
println "Keys from json2 : ${obj2Keys}"
assert obj1Keys == obj2Keys