Hi sukanya
Here you go, just look at below code snippet and modify it accordingly if you need any:
//This is for extracting Next Link data
//imports
import groovy.json.JsonSlurper
//grab the response
def ResponseMessage = messageExchange.response.responseContent
//define a JsonSlurper
def jsonSlurper = new JsonSlurper().parseText(ResponseMessage)
//verify the slurper isn't empty
assert !(jsonSlurper.isEmpty())
def NextData = jsonSlurper.Links.Next
//it will store the value of Next in TestCase level properties
context.testCase.setPropertyValue("NextData",NextData)
//This is For navTok Data
NextData = NextData.toString()
strLen = NextData.length()
if(NextData.contains("navTok"))
{
navtokIndex = NextData.lastIndexOf("navTok")
navtokIndex = navtokIndex + 7
navtokString = NextData.substring(navtokIndex, strLen)
context.testCase.setPropertyValue("navTokData",navtokString)
}
else
{
assert(true:false):"String not found"
}
Do mark it as a solution if it fulfills your need. :smileyvery-happy:
Cheers,
Himanshu