How to test a JSON response with multiple objects with the same name
Hi,
I'm looking for some ideas on how we can test one of our new API's. The API in question will return a JSON response similar to the one outlined below:
{ "testJSON" : [ { "test1" : "111", "test2" : "ABC" }, { "test1" : "222", "test2" : "DEF" } ] }
As the JSON response can have multiple objects with the same name (e.g. we will have multiple objects called test1), we've been having difficulties finding a way to create assertions to allow us to check that the each object contains the correct value without manually creating properties for each object.
Ideally, we want to be able to use an Excel spreadsheet which will show each JSON section on a separate row (e.g. the columns will be titled test1 and test2 and each row will display the expected content for each section of the JSON). We'd then want an assertion test step to compare the JSON response to this spreadsheet.
We've tried a few methods of doing this in SoapUI (we've tried data sources, assertion test steps, data sinks etc) but they all start to fail as soon as we have more than one object with the same name.
My guess is we'll need to write a groovy script to do this, but I just wondered if anyone had any experience with JSON's in this format and how they managed to get around the above issues?
Please let me know if you want me to add any more info into the question.
Thanks in advance for your help.
Matt