How do I get the value of a specific parameter?

Maybe I’m too stupid, but after 2 days of searching, I still haven’t found an answer.
I was given the task, I need to get the parameter value from json, for example:
https://reqres.in/api/users/2

{
“data”: {
“id”: 2,
“email”: “janet.weaver@reqres.in”,
“first_name”: “Janet”,
“last_name”: “Weaver”,
“avatar”: “https://reqres.in/img/faces/2-image.jpg”
},
“support”: {
“url”: “Reqres - A hosted REST-API ready to respond to your AJAX requests”,
“text”: “To keep ReqRes free, contributions towards server costs are appreciated!”
}
}

And I only need to get the value of the id and email parameter, how can I do this with postman

Hi @docking-module-physi,

Here is an example code which you can enter in the Tests tab of the request. This will load the specified values from the response.

var jsonData = pm.response.json();
console.log("The ID is " + jsonData.data.id);
console.log("The email is " + jsonData.data.email);

If you look in Postman’s Console tab, you will see the values have been extracted:

image

There are further examples in the Test script examples help documentation: Testing response body

1 Like