How to fetch the keys of response body in test script

Using below script i could able to fetch value of key in response body , Could you please let me know how can i fetch key from response body ?

var data = JSON.parse(responseBody)
value = data.key

You can use Object.keys like this:

const response = pm.response.json();
const keys = Object.keys(response);

JavaScript Documentation:


Hi vdespa,

This helped me lot, Thank you so much !

1 Like