0

I've 2 text files having json replies which I would like to compare everyline. Below is the code snippet I've been trying.

if (expectedResponse == actualResponse){  
    log.info "PASS"  
}   
else {  
    log.info "FAIL"  
}  

}

While comparing the files, is it must to read lines and do so? Any suggestions please..

Umesh Kumar
  • 127
  • 1
  • 1
  • 9
  • 1
    Possible duplicate of [Groovy compare two json with unknown nodes names and values](https://stackoverflow.com/questions/33410830/groovy-compare-two-json-with-unknown-nodes-names-and-values) – Hammelkeule Jun 06 '17 at 08:38

1 Answers1

0
import groovy.json.JsonSlurper;

def a= new JsonSlurper().parse(new File("path-to-a.json"))
def b= new JsonSlurper().parse(new File("path-to-b.json"))

assert a==b
//or you can do if instead of assert
daggett
  • 26,404
  • 3
  • 40
  • 56