Parsing JSON array in CXone Studio SNIPPET action using GetRESTProxy

We are migrating some logic from our Terraform-defined integrations into a CXone Studio flow to reduce latency. The specific requirement is to fetch a list of available skills for a user via the REST API and then iterate through that list to find a match for a specific campaign.

The challenge lies in the SNIPPET action. We are using the GetRESTProxy object to make a GET request to /api/v2/users/{userId}/skills. The call succeeds, and we can see the response body in the logs. However, parsing the resulting JSON array into a usable format within the snippet logic is proving difficult.

Here is the current snippet code:

SET restProxy = GetRESTProxy();
SET url = "https://{org}.mypurecloud.com/api/v2/users/{userId}/skills";
SET restProxy.setMethod("GET");
SET restProxy.setURL(url);

// Auth is handled via a previous step setting the bearer token
SET restProxy.setHeader("Authorization", "Bearer " + $session.authToken);

SET response = restProxy.sendRequest();

SET statusCode = response.getStatusCode();
SET responseBody = response.getBody();

// Attempting to parse
IF statusCode == 200 THEN
 // This part fails or returns null
 SET skillsList = ParseJSON(responseBody);
 SET skillCount = skillsList.size();
 // Loop logic would go here
END IF;

The ParseJSON function is not available in the standard Studio snippet library in the way I expected. The responseBody comes back as a string. When I try to assign it to a variable and access array indices, the flow throws a runtime error stating that the object is not iterable.

Is there a native way to deserialize the JSON string returned by GetRESTProxy into a map or array object within the SNIPPET action? Or do we need to rely on a separate Data Action to handle the transformation before bringing it back into the snippet?

We want to avoid adding extra hops if the parsing can be done inline. The documentation for Studio scripting is quite sparse on data type conversion for REST responses.

Studio snippets don’t parse JSON arrays natively. You’ll need to handle the deserialization in your client app or use a Data Action with a custom script instead of trying to force GetRESTProxy to do string parsing.