Forum Discussion
Hey, You can write groovy code for JsonPath parser and verify the results. Follow this line of code:-
This is your JSON:-
{
"apiVersion": "0.1",
"errors": null,
"infos": null,
}
Get the path of each and every key whichever you wan to assert and then verify the results:-
def response = '''
{
"apiVersion": "0.1",
"errors": null,
"infos": null
}'''
def slurper = new JsonSlurper();
def inputdata= slurper.parseText(response)
def finalValueToRead = "$.apiVersion"
def actualValue = parse(inputdata).read(strFinalValueToRead).toString()
actualValue will print 0.1 .. Similarly you do for others also. Better way is create a keyword names as "Check_Value_Present" and call it every time for the path verification.. That's all.
Thanks avidCoder. I will give this a go and update whether this worked.