Forum Discussion
KarelHusa
3 years agoChampion Level 3
Hi krispokkuluri ,
you can try to analyze the JSON with JSONPath, e.g.:
import com.jayway.jsonpath.JsonPath
def json = new File("C:\\MyPath\\MyFile.json").text
def maxGrantDetailId = JsonPath.read(json, '$..GrantDetailId.max()')
def grantInfo = JsonPath.read(json, "\$..*[?(@.GrantDetailId == ${maxGrantDetailId})]")
assert grantInfo.Quantity[0] == 10
You can check your JSONPath at https://jsonpath.herokuapp.com/ and then apply it inGroovy.
Another option could be to utilize the JSON DataSource test step.
Best regards,
Karel