# Running a collection with a Json file

**URL:** <https://community.postman.com/t/running-a-collection-with-a-json-file/34890>\
**Category:** Help Hub\
**Tags:** tests, collections\
**Created:** [April 29, 2022, 1:47pm UTC](https://community.postman.com/t/running-a-collection-with-a-json-file/34890 "2022-04-29T13:47:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![automationtester2496](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@automationtester2496](https://community.postman.com/u/automationtester2496)\
**Post date:** [April 29, 2022, 1:47pm UTC](https://community.postman.com/t/running-a-collection-with-a-json-file/34890/1 "2022-04-29T13:47:23Z")

</div>

I am trying to pass data from a JSON file, which has two data objects. In the test script in postman I select them through index positions. But when I run the tests through the runner I see the first iteration passes but in the output it would run the second index data which would show as failed. Is there anyway in the test output to not show the second tests under the first iteration results?

**This is the actual response from the API**

 ![actualBodyResponse](https://us1.discourse-cdn.com/getpostman/original/2X/5/5534919ee1975a9cf1455bfd381b3d15d0753eec.png)

**This is the json file I upload to the runner**

 ![JsonfileScreenshot](https://us1.discourse-cdn.com/getpostman/original/2X/4/437a7db5c7e328b587ef2a9e2d7baf3f709a195b.png)

**This is the result from the first iteration which includes the second iteration results as well (failed ones)**

 ![firstScreenshot](https://us1.discourse-cdn.com/getpostman/original/2X/1/1804961b7c372bf2ae38f72972399e158cdc643c.png)

**This is the result from the second iteration which includes the first iteration results as well (failed ones)**

 ![secondScreenshot](https://us1.discourse-cdn.com/getpostman/original/3X/b/3/b3b29937f89639823fd74c143af9a81aa322a8fa.png)

```auto
pm.test("Verify Person Name - Borrower", () => {
  const responseJson = pm.response.json();
  pm.expect(responseJson.response.validAccounts[0].firstName).to.eql(pm.iterationData.get('firstName'));
});

pm.test("Verify Account Number - Borrower", () => {
  const responseJson = pm.response.json();
  pm.expect(responseJson.response.validAccounts[0].accountNumber).to.eql(pm.iterationData.get('accountNumber'));
});

pm.test("Verify Account Number 14 - Borrower", () => {
  const responseJson = pm.response.json();
  pm.expect(responseJson.response.validAccounts[0].accountNumber14).to.eql(pm.iterationData.get('accountNumber14'));
});

pm.test("Verify Person Name - Co Borrower", () => {
  const responseJson = pm.response.json();
  pm.expect(responseJson.response.validAccounts[1].firstName).to.eql(pm.iterationData.get('firstName'));
});

pm.test("Verify Account Number - Co Borrower", () => {
  const responseJson = pm.response.json();
  pm.expect(responseJson.response.validAccounts[1].accountNumber).to.eql(pm.iterationData.get('accountNumber'));
});

pm.test("Verify Account Number 14 - Co Borrower", () => {
  const responseJson = pm.response.json();
  pm.expect(responseJson.response.validAccounts[1].accountNumber14).to.eql(pm.iterationData.get('accountNumber14'));
});

```

---

<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:** [May 2, 2022, 6:08pm UTC](https://community.postman.com/t/running-a-collection-with-a-json-file/34890/2 "2022-05-02T18:08:32Z")

</div>

Hi @automationtester2496

You could probably get around it with an if statement… maybe…

`pm.info.iteration` would give you the current iteration number (starting at 0). So maybe you could do something like this;

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/4/d4e6840967a9a4c3cc803c91b0da921d4f79b5ca.png)

---

<div class="post-metadata">

**Author:** ![automationtester2496](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@automationtester2496](https://community.postman.com/u/automationtester2496)\
**Post date:** [May 2, 2022, 6:31pm UTC](https://community.postman.com/t/running-a-collection-with-a-json-file/34890/4 "2022-05-02T18:31:49Z")

</div>

Thank you that was it.
