# How to ignore a specific field in pm.expect irrespective of its level and occurances

**URL:** <https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect-irrespective-of-its-level-and-occurances/25838>\
**Category:** Help Hub\
**Created:** [July 16, 2021, 2:10pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect-irrespective-of-its-level-and-occurances/25838 "2021-07-16T14:10:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akram\_Shaik](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@Akram\_Shaik](https://community.postman.com/u/Akram_Shaik)\
**Post date:** [July 16, 2021, 2:10pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect-irrespective-of-its-level-and-occurances/25838/1 "2021-07-16T14:10:56Z")

</div>

Our API response has fields like timestamp, GUID’s etc which I would like to exclude from the comparison in pm.expect.

How can we exclude a field completely from the comparison in expect like in my case the response looks like.

{  
“userId”: “This is a random Guid”,  
“dateCreated”: “This is a dynamic timestamp”,  
“firstName” : “Test”,  
“person”:{  
“firstName”:“test1”  
}  
}

So in this data, I would like to compare my whole response JSON with an expected JSON(which I have in a separate variable).  
I can compare this using pm.expect(actualJSON).to.eql(expectedJSON);

Just that i want to ignore specific fields.

Pls suggest a way to do this.

---

<div class="post-metadata">

**Author:** ![pranavdavar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/pranavdavar/32/9152_2.png) [@pranavdavar](https://community.postman.com/u/pranavdavar)\
**Post date:** [July 19, 2021, 6:11am UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect-irrespective-of-its-level-and-occurances/25838/2 "2021-07-19T06:11:03Z")

</div>

Hi @Akram_Shaik,

One way I could think of is, to remove those key-value pairs from the response output and expected output which you don’t want to compare.

Once you have the JSON data in the expected format, you can use expect to compare.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [July 19, 2021, 7:17am UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect-irrespective-of-its-level-and-occurances/25838/3 "2021-07-19T07:17:16Z")

</div>

Hi @Akram_Shaik , Yes as @pranavdavar suggested you build your expected response.

Please check if this [pick method](https://lodash.com/docs/4.17.15#pick) helps you. This will help you to pick the expected attributes to be listed, and you can store that as a expected response to proceed further 😊

I have built a sample one in my public workspace, please check this for more details.

[https://www.postman.com/bpricilla/workspace/pricilla-s-api-space/request/12539800-50968829-5cf3-4f6c-be50-2320517f9fed](https://www.postman.com/bpricilla/workspace/pricilla-s-api-space/request/12539800-50968829-5cf3-4f6c-be50-2320517f9fed)

Please let me know if there’s any other doubts 🙂

---

<div class="post-metadata">

**Author:** ![Akram\_Shaik](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@Akram\_Shaik](https://community.postman.com/u/Akram_Shaik)\
**Post date:** [July 19, 2021, 3:02pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect-irrespective-of-its-level-and-occurances/25838/4 "2021-07-19T15:02:35Z")

</div>

@pranavdavar thanks for your response. But it json is too large and there are too many values which needs to be excluded then its going be a very large script and also difficult to maintain. I am trying to find is there any function which ignore/delete the property irrespective of level. So that i don’t to specifiy entire structure of the property(Ex: person.firstName), instead just pass (firstName)

---

<div class="post-metadata">

**Author:** ![Akram\_Shaik](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@Akram\_Shaik](https://community.postman.com/u/Akram_Shaik)\
**Post date:** [July 19, 2021, 3:13pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect-irrespective-of-its-level-and-occurances/25838/5 "2021-07-19T15:13:19Z")

</div>

@bpricilla thanks for your suggestion that really helps.  
Actually i am looking to compare two big json responses using pm.expect. if there is any difference in the values in then it should fail.

For example  
**Response1:**  
{  
“userId”: “This is a random Guid”,  
“dateCreated”: “This is a dynamic timestamp”,  
“firstName” : “Test”,  
“person”:{  
“firstName”:“test1”  
}  
}

**Resposne-2:**  
{  
“userId”: “This is a random Guid”,  
“dateCreated”: “This is a dynamic timestamp”,  
“firstName” : “Test1”,  
“person”:{  
“firstName”:“test”  
}  
}

the above responses should be compared by excluding firstName property
