How to visualize or format the API response in POSTMAN.
To format the API response specific attribute in formatted view to unscape the special character (\n) newline.
Sample Response:
{"first_name":"shivansh\nsecond_value\nthird\nfourth_value\nfinal value","last_name":"seth"}
Data To format:
"first_name":"shivansh\nsecond_value\nthird\nfourth_value\nfinal value"
Expected Output:
Please follow the below steps to run the script.
open postman and enter the API endpoint whose response you want to format/visualize.
Select the 'Tests' tab
Write the below script in "tests" tab
pm.visualizer.set("<pre>{{text}}</pre>", { text: pm.response.json().first_name });
Here first_name
is the API response JSON attribute which we are formatting.
Run the API "send' and see the formatted output in 'Visualize' Tab.