Reputation: 226
How to Assert if field in NULL in JSON Response from SOAP UI
Example: Data looks like this I need to assert if Children is null using Assert option from Soap UI.
{
"request": {
"parameters": {"SOURCE_NAME": {
"name": "Members_Sheet1",
"caseSensitivity": "CASE_SENSITIVE",
"inputMatchingOperator": "EXACT"
}},
"metadata": {}
},
"data": {
"results": [{"data": {"Members_Sheet1": [
{
"Sl No": 1,
"Member ID": 70000001,
"Member Name": "Fly Dorami",
"Location": "New York",
"DOB": "4/12/2008",
"Gender": "M",
"Marital Status": "Single",
"Children": "",
"Ethnicity": "Asian",
"Insurance Plan ID": 2002,
"Annual Income ($)": 0,
"Twitter User ID": 548900028
Upvotes: 2
Views: 3498
Reputation: 326
The JSON you quoted is having empty string in Children, its not a NULL. For doing this you may need to convert the JSON to XML using ResponseAsXML property enabled.
Alternative is to use groovy script assertion;
import groovy.json.JsonSlurper
def response = messageExchange.response.responseContent
def slurper = new JsonSlurper()
def json = slurper.parseText response
// json variable has all your data
assert // statement
Upvotes: 6