'Parsing data array from response body json

My task is to create a new record in the database using a unique identifier. I have to contact the service using the GET method, from which I get a set of unique identifiers, then write them in the collection variables and then use them in my tests. I get the answer in this form. I understand that I have to parse the array of answers and write the result in a variable.

response body:

response body

starting parse:

starting parse



Solution 1:[1]

I don't know how correctly I solved my question, but it works the way I need it to. The answer is parsed into individual identifiers:

var jsonData = JSON.parse(responseBody);
pm.collectionVariables.set("dealRef1", jsonData[0]);
pm.collectionVariables.set("dealRef2", jsonData[1]);
pm.collectionVariables.set("dealRef3", jsonData[2]);
pm.collectionVariables.set("dealRef4", jsonData[3]);
pm.collectionVariables.set("dealRef5", jsonData[4]);

Response Body:

[
"1BPMPOST9O5L0F8E9NPX",
"1BPMPOSTI5I10F8E9NPF",
"1BPMPOST0LFP0F8E9NQ5",
"1BPMPOSTIBP80F8E9NQI",
"1BPMPOSTQILO0F8E9NQC"
]

?nd written to Collection Variables, which I then call in my further tests.

Collection Variables:

dealRef1 - 1BPMPOST9O5L0F8E9NPX
dealRef1 - 1BPMPOSTI5I10F8E9NPF
dealRef1 - 1BPMPOST0LFP0F8E9NQ5
dealRef1 - 1BPMPOSTIBP80F8E9NQI
dealRef1 - 1BPMPOSTQILO0F8E9NQC

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ??????? ?????????