2017-06-06 60 views
0

我有2个文本文件具有json回复,我想比较everyline。以下是我一直在尝试的代码片段。如何比较具有json回复的两个文本文件

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

}

在比较中的文件,就是它必须读线和这样做呢?任何建议,请..

+1

的[Groovy的比较两个JSON与未知节点的名称和值]可能的复制(https://stackoverflow.com/questions/33410830/groovy-compare-two-json-with-unknown -nodes-名称和值) – Hammelkeule

回答

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