# An assertion to check whether the array in the response body match with a JSON file

**URL:** <https://community.postman.com/t/an-assertion-to-check-whether-the-array-in-the-response-body-match-with-a-json-file/26603>\
**Category:** Help Hub\
**Tags:** tests, responseassertion, array\
**Created:** [August 10, 2021, 10:44am UTC](https://community.postman.com/t/an-assertion-to-check-whether-the-array-in-the-response-body-match-with-a-json-file/26603 "2021-08-10T10:44:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![docking-module-geos3](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@docking-module-geos3](https://community.postman.com/u/docking-module-geos3)\
**Post date:** [August 10, 2021, 10:44am UTC](https://community.postman.com/t/an-assertion-to-check-whether-the-array-in-the-response-body-match-with-a-json-file/26603/1 "2021-08-10T10:44:41Z")

</div>

Hi,  
I want to add an assertion to check whether the array in the response body match with a JSON file  
In the below example, I have an array “ErrorCode” with 3 elements (in reality, there are a lot of returned data so I wanna use a data file (JSON,CSV) and use Run Collection to check faster)

I want to check whether the array in the response body matches with a JSON file. How could I do that?  
A. Json file as below:

> Blockquote  
> {  
> “ErrorCode”:[  
> {  
> “Id”:1,  
> “CodeCategory”:null,  
> “CodeName”:“ErrCodeA”,  
> “Removal\_flag”: true  
> },  
> {  
> “Id”:2,  
> “CodeCategory”:null,  
> “CodeName”:“ErrCodeB”,  
> “Removal\_flag”: false  
> },  
> {  
> “Id”:3,  
> “CodeCategory”:null,  
> “CodeName”:“ErrCode3”,  
> “Removal\_flag”: true  
> }  
> ]  
> }  
> Blockquote

B. Response body as below:

> Blockquote  
> {  
> “ErrorCode”:[  
> {  
> “Id”:1,  
> “CodeCategory”:null,  
> “CodeName”:“ErrCode1”,  
> “Removal\_flag”: false  
> },  
> {  
> “Id”:2,  
> “CodeCategory”:null,  
> “CodeName”:“ErrCode2”,  
> “Removal\_flag”: false  
> },  
> {  
> “Id”:3,  
> “CodeCategory”:null,  
> “CodeName”:“ErrCode3”,  
> “Removal\_flag”: true  
> }  
> ]  
> }  
> Blockquote

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [August 11, 2021, 10:18am UTC](https://community.postman.com/t/an-assertion-to-check-whether-the-array-in-the-response-body-match-with-a-json-file/26603/2 "2021-08-11T10:18:40Z")

</div>

you cannot call external files in postman , but can store the content in a variable and use

```auto

pm.expect(pm.response.json()).to.be.deep.eq({

    "ErrorCode": [

        {

            "Id": 1,

            "CodeCategory": null,

            "CodeName": "ErrCode1",

            "Removal_flag": false

        },

        {

            "Id": 2,

            "CodeCategory": null,

            "CodeName": "ErrCode2",

            "Removal_flag": false

        },

        {

            "Id": 3,

            "CodeCategory": null,

            "CodeName": "ErrCode3",

            "Removal_flag": true

        }

    ]

})

```
