first i am hitting the url , then i’m getting json response. from that json response i need one value.
url : http://www.mrhaki.com/samples/sample.json
Json :
{ "user": { "name": "mrhaki", "age": 38, "interests": ["Groovy", "Grails"] }}I need the value of name.please help me
import groovy.json.JsonSlurperString response = '''{ "user": { "name": "mrhaki", "age": 38, "interests": ["Groovy", "Grails"] }}'''JsonSlurper jsl = new JsonSlurper()Map parsedResponse = jsl.parseText(response)println parsedResponse.user.name
2 Likes
Marek Melocik said:
import groovy.json.JsonSlurperString response = '''{ "user": { "name": "mrhaki", "age": 38, "interests": ["Groovy", "Grails"] }}'''JsonSlurper jsl = new JsonSlurper()Map parsedResponse = jsl.parseText(response)println parsedResponse.user.name
thank you so much .it is working
Marek Melocik said:
import groovy.json.JsonSlurperString response = '''{ "user": { "name": "mrhaki", "age": 38, "interests": ["Groovy", "Grails"] }}'''JsonSlurper jsl = new JsonSlurper()Map parsedResponse = jsl.parseText(response)println parsedResponse.user.name
Hi Marek, is the above possible in Katalon Recorder and can you please assist with steps?
Hi Schalk,
this is possible in Script mode. The only thing you need is to copy this code and paste it into your test case. Of course, use your own JSON address.