2

Could someone please me understand how to validate a list of items from the response. Say the response looks something like below,

{  
   "store":{  
      "book":[  
         {  
            "author":"Nigel Rees",
            "category":"reference",
            "price":8.95,
            "title":"Sayings of the Century"
         },
         {  
            "author":"Evelyn Waugh",
            "category":"fiction",
            "price":12.99,
            "title":"Sword of Honour"
         },
         {  
            "author":"Herman Melville",
            "category":"fiction",
            "isbn":"0-553-21311-3",
            "price":8.99,
            "title":"Moby Dick"
         },
         {  
            "author":"J. R. R. Tolkien",
            "category":"fiction",
            "isbn":"0-395-19395-8",
            "price":22.99,
            "title":"The Lord of the Rings"
         }
      ]
   }
}

The element Book has four lists under it with different data, now if I want to validate the author name and the price sequentially (in a loop for instance) how can I achieve that..?

I usually convert the response into a Json document and then validate, but in this case, if I use the Json path "Store.book.author", out of the four lists from the response, which list would it refer to..? That's where my confusion is.

4

2 に答える 2