MauraR
12 years agoOccasional Contributor
[Resolved] help in asserting json response
Hello,
Can anyone please help me how I can assert the following json response?
{"2709": {
"id": 2709,
"status": "-1",
"comment": "",
"summary": "test summary"
}}
1. I need to assert that the value in "2709" is not null - this gets generated every time I send a POST. This value can be from 4 digits or more
2. I also need to assert that all fields are not empty - i.e. id, status, comment, and summary.
This is what I have started with, but I can't get the fields that I need to assert
import groovy.json.JsonSlurper
def response = messageExchange.response.responseContent
def slurper = new JsonSlurper()
def json = slurper.parseText response
Thanks,
MR
Can anyone please help me how I can assert the following json response?
{"2709": {
"id": 2709,
"status": "-1",
"comment": "",
"summary": "test summary"
}}
1. I need to assert that the value in "2709" is not null - this gets generated every time I send a POST. This value can be from 4 digits or more
2. I also need to assert that all fields are not empty - i.e. id, status, comment, and summary.
This is what I have started with, but I can't get the fields that I need to assert
import groovy.json.JsonSlurper
def response = messageExchange.response.responseContent
def slurper = new JsonSlurper()
def json = slurper.parseText response
Thanks,
MR