Assert portion of JSON with nested objects and arrays


I have an application that uses an API to retrieve data to display to the user in a chart.

I would like to use Postman to ensure the data being returned is consistent over time ( eg value A for July 21, 11:05 pm is the same today as it was originally) as we have had database issues previously.

The data is included in a number of nested objects and comprise just one portion of the API return. I don’t want to compare the entire JSON as there is continuing development on this project that will likely affect some of these other objects and arrays.

I thought there might be some type of JSON.includes function but as of yet cannot find. See screenshot with a portion of the sample JSON with the portion I want to include in the assertion highlighted in yellow.

Hi @kirbywanner,

Welcome to the Postman community! Using the pm library you would be able to check the data and group field in the response against the expected data with the following test script assuming you want to get only the first record from series_list:

  1. pm.test(“check data is expected”, function () {
    var jsonData = pm.response.json();
  2. pm.test(“check group is expected”, function () {
    var jsonData = pm.response.json();

Since series_list is an array, you will not be able to access just the values in data and group for all the records, you would have to test the series_list array itself which would be done as given below:
3. pm.test(“check series list is expected”, function () {
var jsonData = pm.response.json();