Validate json array response

I have a simple api GET request and the response body is just like below. I want to validate the response and check whether below conditions are met.

  1. Response array size should always be 2.

  2. In each of the array item, the “build.time” value should be a date time.

  3. In each of the array item, the “build.artifact” value should be equals to “main_component”.

  4. “build.name” value of the 1st array item should equals to “web app”

  5. “build.name” value of the 2nd array item should equals to “back-end”.

    [
    {
    “build.time”: “2020-01-24 02:07:03 UTC”,
    “build.artifact”: “main_component”,
    “build.name”: “web app”,
    “build.version”: “1.0.0”
    },
    {
    “build.time”: “2019-07-10 15:26:18 UTC”,
    “build.artifact”: “main_component”,
    “build.name”: “back-end”,
    “build.version”: “1.0.1”
    }
    ]

Hi @hondaputha

You can perform this validation by using the test scripts feature in Postman. These scripts are written in JavaScript and ran after Postman receives the JSON response.

You can then store the test results in Environment variables. These variables can be read by other APIs to perform further tests.