# Save into variable a Json value from response and that is stored inside an object

**URL:** <https://community.postman.com/t/save-into-variable-a-json-value-from-response-and-that-is-stored-inside-an-object/37362>\
**Category:** Help Hub\
**Tags:** tests, variables, json\
**Created:** [July 20, 2022, 12:29pm UTC](https://community.postman.com/t/save-into-variable-a-json-value-from-response-and-that-is-stored-inside-an-object/37362 "2022-07-20T12:29:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibragroupsantander](https://avatars.discourse-cdn.com/v4/letter/i/b2d939/32.png) [@ibragroupsantander](https://community.postman.com/u/ibragroupsantander)\
**Post date:** [July 20, 2022, 12:29pm UTC](https://community.postman.com/t/save-into-variable-a-json-value-from-response-and-that-is-stored-inside-an-object/37362/1 "2022-07-20T12:29:16Z")

</div>

On the response body, inside an object there is a value (name) that i need to convert into variable. Response goes like this;

“timestamp”: “20/07/2022 13:35:23”,  
“status”: 200,  
“description”: “OK”,  
“message”: “XXXXXX”,  
“requestId”: “XXXXXXXXXXXXXXX”,  
“data”: [  
{  
“name”: “XXXXXX”,  
“tenant”: “XXXXX”,  
“vcenteruuid”: “XXXXXXXXXX”,  
“vmOwner”: “XXXXXXXXX”,  
“creationDate\_utc”: “XXXXXXX”,  
“deleteDate\_utc”: null,  
“archiveDate\_utc”: null,  
“currentStatus”: 1,  
“requestStatus”: null,  
“assetId”: null,  
“serviceClass”: “Bronze”,  
“clusterType”: “Multicluster”,  
“description”: “XXXXXXX”,  
“serviceIp”: “XXXXXXXXX”,  
“adminIp”: “XXXXXX”,  
“az”: “XX”,  
“environment”: “DEV”,  
“os”: “XXXXXXXXX)”,  
“cpu”: “X”,  
“memory”: “XXXXXXX”,  
“storage”: “XXXXXX”,  
“networkZone”: “XXXXX”,  
“commitmentPeriod”: “XXXXXXXX”,  
“businessService”: “XXXXXX”,  
“availabilitySet”: null,  
“origin”: “green”,  
“vcenterUrl”: “XXXXXXXXXX”,  
“customTags”: null  
}

Since “name” is to be found inside “Data” object i don´t know how to interact with it and store it into a variable.

Im very new into this; regards

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

---

<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:** [July 20, 2022, 2:47pm UTC](https://community.postman.com/t/save-into-variable-a-json-value-from-response-and-that-is-stored-inside-an-object/37362/2 "2022-07-20T14:47:19Z")

</div>

Hi @ibragroupsantander

You would need to specify the ‘data’ array index.

Try this;

```auto
const response = pm.response.json();
console.log(response.data[0].name);

```

If you need ‘name’ from more than just the first index then you would likely need to build it into a for loop to cycle through the entire array.

---

<div class="post-metadata">

**Author:** ![ibragroupsantander](https://avatars.discourse-cdn.com/v4/letter/i/b2d939/32.png) [@ibragroupsantander](https://community.postman.com/u/ibragroupsantander)\
**Post date:** [July 21, 2022, 6:01am UTC](https://community.postman.com/t/save-into-variable-a-json-value-from-response-and-that-is-stored-inside-an-object/37362/3 "2022-07-21T06:01:02Z")

</div>

it worked!!!; thank you so much!!!
