How to set id in env from this response

{
“data”: {
“insert_pro_one”: {
“id”: “3453”,
“name”: " Test2",
“details”: “sample project”
}
}
}
this is the response which I am getting , I need to set id from this to env .how to do that?

Can you please use the preformatted text option in the editor to post code or example responses.

It stops everything getting aligned to the left.

{
    "data": {
        "insert_pro_one": {
            "id": "3453",
            "name": "Test2",
            "details": "sample project"
        }
    }
}

This way, you can easily see which element belongs to what.

Some core syntax rules.

  • Data is in name/value pairs
  • Data is separated by commas
  • Curly braces hold objects
  • Square brackets hold arrays

Values can be strings, but also objects or arrays. You can have objects within objects (as in your example), and arrays within arrays.

In your example response, you have an object called “data”, which contains another object called “insert_pro_one” which contains data elements.

As you only have one element under data, you might as well parse directly to that element.

The following example will show you how to get the id.

const response = pm.response.json().data;

let id = response.insert_pro_one.id;

console.log(id); // 3453