'How do I check for presence of keys in the object of a JSON response in restAssured Java

I have an endpoint that returns the json response as below:

"abc" : [
{
   "name" : "XZ",
   "id" : "1234",
   "action" : {
       "attributes" : {
             "abcRouter" : true
           },
        "url" : "<somevaluehere>"
      },
{
   "name" : "XZ2",
   "id" : "12356",
   "action" : {
       "attributes" : {
             "abc" : true
           },
        "url" : "<somevaluehere>"
      },

I have already defined POJO class to contain the JSON response and able> to access the action object and attributes object. Based on certain condition I need to validate that the attributes object within the action can contain only "abc" or "abcRouter" as allowed keys.

How can this be implemented in Java?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source