Stripping characters from response


A newbie question -

the response I get is in the following form:
“unitnumber”: “255272”,
“name”: “unit-272”,
“unittype”: 7,


How do I extract the json response that is enclosed in the [ brackets ] ?


Hi @eyalasko,

You don’t need to strip the characters as such - they are a valid part of the response.

The brackets indicate that the response is an array of items. If you want to get at the properties within, you need to first declare the index of the item that you wish to select. (The index will start from 0, so the first item is always zero)

For example, this will print “255272” to the Postman console:

var jsonData = pm.response.json();

If you’re certain that your response will only ever contain one item, you can save yourself some typing by specifying the index in the first variable, for example:

var firstItem = pm.response.json()[0];
1 Like