How to remove curly braces of the response body using tests

How do I remove the curly braces in the JSON response body
example response :
“id”: “12345”,
“store”: “walmart”,
“location”: “newyork”

How to store the above json into a variable by removing the curly braces in tests tab?

@rajpostmanacc :wave: Welcome to the community!

Not sure if you are really looking to “remove” curly braces, but I guess you are after parsing the response data.

This question has been asked a few times already, so you may want to check those out: Search results for 'parse JSON response' - Postman Community

You can use the Postman’s pm.response object’s functions to read and manipulate the response.

For your specific case the following should work:

let resJson = pm.response.json(); // Parse JSON response and store in a variable

You can now use it as follows:

console.log(; // Should print `Walmart` based on your example data

I suggest your check out the other community posts on response parsing, as well as this Postman learning centre doc Test script examples | Postman Learning Center to better your understanding on how to handle responses in scripts.

If you remove the curly brackets, then this will no longer be a valid JSON object.

If you want this as a single variable, you would keep it as it currently looks (with the curly brackets) and store this by using JSON.stringify() and then when you want to retrieve it, you would JSON.parse().

In order to give you a better response, we need to know a bit more about the use case. What are you going to do with this? I’m guessing you need to use part of it, or all of it in a subsequent request?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.