# How to check data type of nested array elements

**URL:** <https://community.postman.com/t/how-to-check-data-type-of-nested-array-elements/10408>\
**Category:** Help Hub\
**Created:** [January 29, 2020, 7:54am UTC](https://community.postman.com/t/how-to-check-data-type-of-nested-array-elements/10408 "2020-01-29T07:54:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohit2330](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@rohit2330](https://community.postman.com/u/rohit2330)\
**Post date:** [January 29, 2020, 7:54am UTC](https://community.postman.com/t/how-to-check-data-type-of-nested-array-elements/10408/1 "2020-01-29T07:54:01Z")

</div>

Hi ,

I want to check data type of below nested array elements i.e. for “id”

```
{
    "name": "Test1",
    "values": [
        {
            "id": "1",
            "value": "Value1",
            "values": [
                {
                    "id": "1",
                    "value": "ABC-1",
                    "values": null
                },
                {
                    "id": "1",
                    "value": "ABC-2",
                    "values": null
                },
                {
                    "id": "1",
                    "value": "ABC-3",
                    "values": null
                },
               ]
        },
        {
            "id": "2",
            "value": "Value2",
            "values": [
                {
                    "id": "2",
                    "value": "PQR1",
                    "values": null
                },
                {
                    "id": "2",
                    "value": "PQR2",
                    "values": null
                },
                {
                    "id": "2",
                    "value": "PQR3",
                    "values": null
                }
            ]
        },

```

Urgent help will be appreciable. Thanks in advance

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 29, 2020, 9:18am UTC](https://community.postman.com/t/how-to-check-data-type-of-nested-array-elements/10408/2 "2020-01-29T09:18:44Z")

</div>

Hey @rohit2330

Welcome to the community! 👋

The quickest way that I can think of is to do a loop through the top-level array and then loop through the nested array:

```
pm.test('Check nested Id data type', () => {
    _.each(pm.response.json().values, (topLevelItem) => {
        _.each(topLevelItem.values, (nestedItem) => {
            pm.expect(nestedItem.id).to.be.a('string')
        })
    })
})  

```

This is not a _final solution_ and should really be refactored to make the code more robust and tolerant to different conditions but as you wanted something quick…here you go 🙂

---

<div class="post-metadata">

**Author:** ![rohit2330](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@rohit2330](https://community.postman.com/u/rohit2330)\
**Post date:** [January 30, 2020, 11:52am UTC](https://community.postman.com/t/how-to-check-data-type-of-nested-array-elements/10408/3 "2020-01-30T11:52:47Z")

</div>

Thank you so much @danny-dainton for your quick help.

---

<div class="post-metadata">

**Author:** ![descent-module-techn](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@descent-module-techn](https://community.postman.com/u/descent-module-techn)\
**Post date:** [January 18, 2021, 2:00pm UTC](https://community.postman.com/t/how-to-check-data-type-of-nested-array-elements/10408/4 "2021-01-18T14:00:39Z")

</div>

how to check the data type of a field in json in postman

example: is ID an integer?
