I am comparing JSON response and JSON File in SOAPUI (ver - 4.6.4, freeware) Groovy script:
import groovy.json.JsonSlurper
import java.io.File
def ResponseMessage = testRunner.testCase.testSteps["Fi - Request 1"].testRequest.response.contentAsString
def jsonResp = new JsonSlurper().parseText(ResponseMessage)
def jsonFile = new File("C:/Users/new_2.json")
def InputJSON = new JsonSlurper().parseFile(jsonFile, 'UTF-8')
assert jsonResp.equals(InputJSON)
But every time it runs a pop up of exception is thrown as:
groovy.lang.MissingMethodException: No signature of method: groovy.json.JsonSlurper.parseFile() is applicable for argument types: (java.io.File, java.lang.String) values: [C:\Users\new_2.json, UTF-8] Possible solutions: parseText(java.lang.String) error at line: 12
It didn't work for parseText either. Treat it as a beginner scripting.
Now I am facing completely new error -
groovy.json.JsonException: Lexing failed on line: 1, column: 1, while reading '', no possible valid JSON value or punctuation could be recognized.error at line: 9
Line 1 of JSON file content: {
"Metadata": {
"DocType": "Report",
"SubType": "",
"Content": {
"Title": "Economic Comment",
"Headline": "",
"Summary": "",
"Blurb": ""
},
"Priority": "1",
"DocumentIDs": {
"DocumentID": {
"label": "",
"type": "",
"level": "",
"value": ""
}
},
Note: this content is incomplete. I cannot paste full JSON here due to security reasons
SOAPUI/lib/groovy-all-*jar
– daggettnew JsonSlurper().parse( jsonFile.newReader("UTF-8") )
– daggett