Skip to main content
1 of 2
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.

Madhi
  • 13
  • 1
  • 3