How to parse service response for camunda forms?

I have service response like this :slight_smile:
[
{
“id”:45345,
“name”:“dfd”

},
{
“id”:45345,
“name”:“dfd”

}
]

and i want to parse this response so that i could write this data in two forms,i know that general parsing in javascrript should be like this ( in http ceonnector) S(response) and then in script task
var id=execution.getVariable(“id”);
var name=execution.getVariable(“name”);
var id=execution.getVariable(“id”);
var name=execution.getVariable(“name”);

but how can i parse more complecated response like the one i have posted here?

@Sally see the discussions here: Evaluate a Json with an Expression

you posted a example a array, so: https://docs.camunda.org/manual/7.7/reference/spin/json/01-reading-json/#work-with-json-arrays

@StephenOTT I want to write similar logic for parsing data, but it can’t instanciate variables:
var data=S(execution.getVariable(“restResponse”));
var jsonData = JSON.parse(data);
for (var i = 0; i < jsonData.counters.length; i++) {
var counter = jsonData.counters[i];
var id = data.elements().get(counter).prop(“id”);
var nameGE = data.elements().get(counter).prop(“name”);

    execution.setVariable("id",id);
    execution.setVariable("nameEN",);

}
is it possible to write end properly execute such logic nisde camnda modeller script task?

the example you have linked me is flexible when you know every time what kind of data you will receive , in my case response content can be changed