Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between pm.response.json() and JSON.parse(responseBody)

What is the fundamental difference between

const json_response = pm.response.json()

and

json_response = JSON.parse(responseBody)
like image 655
Lexamenrf Avatar asked Oct 20 '25 14:10

Lexamenrf


1 Answers

In the Postman sandbox context, JSON.parse(responseBody) and pm.response.json() is doing the same thing.

The pm.* API hasn't been in the product the whole time and was introduced to cover lots of different actions that users would normally take when accessing things like, the response body.

Previously, users would use JSON.parse(responseBody) in the sandbox environment to get this data.

Here's the full list of the pm.* API methods but this can also be seen in the app with the auto-suggestion feature when you type pm.

https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/

I would personally recommend that you use the pm.repsonse.json() method in the app.

like image 177
Danny Dainton Avatar answered Oct 22 '25 04:10

Danny Dainton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!