# Creating assertion to "numeric" object

**URL:** <https://community.postman.com/t/creating-assertion-to-numeric-object/25315>\
**Category:** Help Hub\
**Created:** [June 29, 2021, 1:22pm UTC](https://community.postman.com/t/creating-assertion-to-numeric-object/25315 "2021-06-29T13:22:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunar-module-meteor3](https://avatars.discourse-cdn.com/v4/letter/l/7feea3/32.png) [@lunar-module-meteor3](https://community.postman.com/u/lunar-module-meteor3)\
**Post date:** [June 29, 2021, 1:22pm UTC](https://community.postman.com/t/creating-assertion-to-numeric-object/25315/1 "2021-06-29T13:22:47Z")

</div>

Hello everybody,

I have a problem with creating assertions regarding to JSON response:

```auto
{
    "8888": [
        {
            "name": "Jerzy",
            "Id": 10
        }
    ]
}

```

As you can see the first object is a “numeric” string. I don’t know how to get to this object.  
If I will have for example normal string like: “list” then assertion should be:

```auto
var jsonData = pm.response.json();
pm.expect(jsonData.list.name).to.eql("Jerzy");

```

Anybody can help me with this issue?

---

<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:** [June 30, 2021, 12:09am UTC](https://community.postman.com/t/creating-assertion-to-numeric-object/25315/2 "2021-06-30T00:09:52Z")

</div>

@lunar-module-meteor3 Welcome to the Community 🥳

Yes, I feel you… You need to think of using a bracket notation to access the elements instead of dot notation.

You can see the [similar thread](https://community.postman.com/t/extract-value-from-a-json-response-body-via-the-test-scripts/11835/5) here to learn more about it.

In your case it should be something like,

```auto
pm.test("Value is as expected", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData['8888'][0]['name']).to.eql("Jerzy");
    pm.expect(jsonData['8888'][0]['Id']).to.eql(10);
});

```

If this is just a subset of response, please update the path to reach the elements! I hope this is helpful 😊

---

<div class="post-metadata">

**Author:** ![lunar-module-meteor3](https://avatars.discourse-cdn.com/v4/letter/l/7feea3/32.png) [@lunar-module-meteor3](https://community.postman.com/u/lunar-module-meteor3)\
**Post date:** [June 30, 2021, 6:48am UTC](https://community.postman.com/t/creating-assertion-to-numeric-object/25315/3 "2021-06-30T06:48:21Z")

</div>

Thank you for your answer.  
Yes, it’s working.

---

<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:** [June 30, 2021, 7:08am UTC](https://community.postman.com/t/creating-assertion-to-numeric-object/25315/4 "2021-06-30T07:08:13Z")

</div>

@lunar-module-meteor3 Good to know 🥳 Do you mind sparing a minute and marking the solution? That would be helpful for the people in future 🙌

---

<div class="post-metadata">

**Author:** ![rosedias](https://avatars.discourse-cdn.com/v4/letter/r/d26b3c/32.png) [@rosedias](https://community.postman.com/u/rosedias)\
**Post date:** [July 9, 2021, 12:45pm UTC](https://community.postman.com/t/creating-assertion-to-numeric-object/25315/5 "2021-07-09T12:45:16Z")

</div>

please @bpricilla help me with this question

{  
“data”: {  
“carteiras”: [  
{  
“data\_atualizacao”: “2021-07-09T09:42:06.3275534”,  
“valor\_total\_carteira\_formatado”: “R$ 50.000,00”,  
“uid”: “”,  
“id\_tagueamento”: “”,  
“acessibilidade”: {  
“mensagem\_atualizacao”: “Última atualização nove de julho de dois mil e vinte e um às nove horas e quarenta e dois minutos”  
},  
“mensagem\_atualizacao”: “Última atualização 09/07/21 às 09:42”,  
“conta”: “”,  
“nome”: “”,  
“tipo\_carteira”: “”,  
“status”: {  
“tipo”: “”,  
“mensagem”: “”  
}  
},  
{  
“data\_atualizacao”: “2021-07-09T09:42:06.3274604”,  
“valor\_total\_carteira\_formatado”: “R$ 0,00”,  
“uid”: “3660\_45wN”,  
“id\_tagueamento”: “bob\_xpmobile”,  
“acessibilidade”: {  
“mensagem\_atualizacao”: “Atualizando conta. Vamos te avisar quando estiver pronto.”  
},

pm.test(“Value is as expected”, function () {  
var jsonData = pm.response.json();  
pm.expect(JSON.data.carteiras[1].acessibilidade.mensagem\_atualizacao).to.eql(“Atualizando conta. Vamos te avisar quando estiver pronto.”);

});

FAIL  
Value is as expected | ReferenceError: carteiras is not defined

---

<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 9, 2021, 2:18pm UTC](https://community.postman.com/t/creating-assertion-to-numeric-object/25315/6 "2021-07-09T14:18:10Z")

</div>

@rosedias Welcome to the community 🥳

Since you haven’t provided the entire response I am giving a wild guess.

1. It should the variable used and you stored the parsed results not as “JSON”

```auto
pm.test(“Value is as expected”, function () {
var jsonData = pm.response.json();
pm.expect(jsonData.data.carteiras[1].acessibilidade['mensagem_atualizacao']).to.eql(“Atualizando conta. Vamos te avisar quando estiver pronto.”);

});

```

As a beginner whenever you are facing issues in JSON parsing, try to use console.log and see how the entire response looks like.

```auto
console.log(jsonData);

```

or you can use [https://jsonpathfinder.com/](https://jsonpathfinder.com/)

Also I have written a blog about this [here](https://bpricilla.medium.com/how-to-easily-locate-your-json-object-in-your-api-response-647549ee8b2).

I hope this helps 😊

---

<div class="post-metadata">

**Author:** ![rosedias](https://avatars.discourse-cdn.com/v4/letter/r/d26b3c/32.png) [@rosedias](https://community.postman.com/u/rosedias)\
**Post date:** [July 9, 2021, 5:39pm UTC](https://community.postman.com/t/creating-assertion-to-numeric-object/25315/7 "2021-07-09T17:39:54Z")

</div>

> [@bpricilla](#):
>
> ```auto
> pm.test(“Value is as expected”, function () {
> var jsonData = pm.response.json();
> pm.expect(jsonData.data.carteiras[1].acessibilidade['mensagem_atualizacao']).to.eql(“Atualizando conta. Vamos te avisar quando estiver pronto.”);
> 
> });
> 
> ```

😍 😍 excellent solved
