# How to ignore a Specific field in pm.expect

**URL:** <https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect/11647>\
**Category:** Help Hub\
**Tags:** tests, variables\
**Created:** [April 1, 2020, 12:17pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect/11647 "2020-04-01T12:17:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sriramku](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@sriramku](https://community.postman.com/u/sriramku)\
**Post date:** [April 1, 2020, 12:17pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect/11647/1 "2020-04-01T12:17:48Z")

</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"
}

```

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.

Thanks

---

<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:** [April 1, 2020, 1:29pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect/11647/2 "2020-04-01T13:29:53Z")

</div>

Hey @sriramku,

Welcome to the community! 👋

As it’s an object, it might be worth taking a look at using the `delete` method.

> **[delete operator - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete)**
>
> The delete operator removes a property from an object. If the property's value is an object and there are no more references to the object, the object held by that property is eventually released automatically.

An example from that link would be:

```
const Employee = {
  firstname: 'John',
  lastname: 'Doe'
}

console.log(Employee.firstname);
// expected output: "John"

delete Employee.firstname;

console.log(Employee.firstname);
// expected output: undefined

```

So for your case, you could use:

```
delete pm.response.json().userId; 
delete pm.response.json().dateCreated;

```

---

<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:07pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect/11647/3 "2021-07-16T14:07:34Z")

</div>

Wants to ignore a specific field irrespective of its level.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [August 23, 2023, 3:58pm UTC](https://community.postman.com/t/how-to-ignore-a-specific-field-in-pm-expect/11647/4 "2023-08-23T15:58:35Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
