# How to test fields in array

**URL:** <https://community.postman.com/t/how-to-test-fields-in-array/37184>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [July 14, 2022, 6:43am UTC](https://community.postman.com/t/how-to-test-fields-in-array/37184 "2022-07-14T06:43:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivaneo47](https://avatars.discourse-cdn.com/v4/letter/i/2bfe46/32.png) [@Ivaneo47](https://community.postman.com/u/Ivaneo47)\
**Post date:** [July 14, 2022, 6:43am UTC](https://community.postman.com/t/how-to-test-fields-in-array/37184/1 "2022-07-14T06:43:16Z")

</div>

Hello guys. I receive a JSON from api and it need to test by Postman

```auto
{
    "d": [
        {
            "id": 1,
            "name": "John",
            "title": "Doe",
            "service": "Postman",
            "tr": [
                {
                    "id": 28,
                    "tId": 237,
                    "la": "p5",
                    "su": "z0",
                    "bo": "y3",
                    "au": {
                        "CAT": "2022-07-08 07:18:28",
                        "CABY": 1254,
                        "UAT": "2022-07-08 07:18:28",
                        "UBY": 1254
                    }
                }
            ],
          }
}

```

My question is, How to test fields in “d” array and “tr” array.  
I need to know, that I have, for example “title” field and “title” field has “Doe”.  
And “tld” field is exit and has 237.  
And CABY field is exit and has 1254.

Please help me with arrays

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [July 14, 2022, 2:08pm UTC](https://community.postman.com/t/how-to-test-fields-in-array/37184/2 "2022-07-14T14:08:10Z")

</div>

Hi @Ivaneo47

You would use something like this.

```auto
const response = pm.response.json();

pm.test("My Tests", () => {
    pm.expect(response.d[0].title).to.eql("Doe");
    pm.expect(response.d[0].tr[0].tId).to.eql(237);
    pm.expect(response.d[0].tr[0].au.CABY).to.eql(1254);
});

```

Note; to access arrays you have to identify the index, in this example, it is [0].
