After setting up a GET request in Postman that retrieves JSON data, I'm looking to extract the values for keys containing a specific substring.
Here's the code snippet I've been testing:
var jsonData = pm.response.json();
var keys = Object.keys(jsonData);
for(var i = 0; i < keys.length; i++)
{
if(keys[i].includes("_number"))
{
console.log(jsonData[keys[i]]);
}
}
Edit: It seems that the issue lies not in identifying the specified substrings, but in retrieving the corresponding values. Accessing a value directly by key (e.g., jsonData.Id) works without issues, yet using a variable seems to be causing trouble.