Skip to main content
added 26 characters in body
Source Link
João Farias
  • 11k
  • 2
  • 20
  • 40

“Output”: [ {

“Output”: [
        {

        "id_": “123”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1983,
         "currentcompany”: null
    },
    {
        "id": “456”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1975,
         "currentcompany”: null        
},
    {
        id": “456”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1990,
        "current_employment": {
         “company number”: 3455,
                   "name": “XYZ Company”,
    }
}

consider the above is the response. I want to validate "id, firstname, last name, state, yearofbirth, current employment is present in response using an array list using a loop.

The problem is iI am able to get the value of every key and validate. but unable to take only "Key" and check if its present.

“Output”: [ {

        "id_": “123”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1983,
         "currentcompany”: null
    },
    {
        "id": “456”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1975,
         "currentcompany”: null        
},
    {
        id": “456”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1990,
        "current_employment": {
         “company number”: 3455,
                   "name": “XYZ Company”,
    }

consider above is the response. I want to validate "id, firstname, last name, state, yearofbirth, current employment is present in response using array list using loop.

The problem is i am able to get the value of every key and validate. but unable to take only "Key" and check if its present.

“Output”: [
        {

        "id_": “123”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1983,
         "currentcompany”: null
    },
    {
        "id": “456”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1975,
         "currentcompany”: null        
},
    {
        id": “456”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1990,
        "current_employment": {
         “company number”: 3455,
                   "name": “XYZ Company”,
    }
}

consider the above is the response. I want to validate "id, firstname, last name, state, yearofbirth, current employment is present in response using an array list using a loop.

The problem is I am able to get the value of every key and validate. but unable to take only "Key" and check if its present.

Source Link
Madhi
  • 13
  • 1
  • 3

How to verify the JSON structure (only Key , Not value) in Response using Rest Assured framework (Java)

“Output”: [ {

        "id_": “123”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1983,
         "currentcompany”: null
    },
    {
        "id": “456”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1975,
         "currentcompany”: null        
},
    {
        id": “456”
        "first_name": “Testing”,
        "last_name": “Validation”,
        "state": “VA”,
        “yearofbirth”: 1990,
        "current_employment": {
         “company number”: 3455,
                   "name": “XYZ Company”,
    }

consider above is the response. I want to validate "id, firstname, last name, state, yearofbirth, current employment is present in response using array list using loop.

The problem is i am able to get the value of every key and validate. but unable to take only "Key" and check if its present.