Studio snippet getrestproxy json parsing issue

Is it possible to directly parse a nested json response returned by getrestproxy in a cxone studio snippet without using intermediate string manipulation? i am calling an internal service via the rest proxy action to fetch user metadata. the response is a valid json object with nested arrays. when i assign the response to a variable using the assign action, it treats the entire payload as a string. accessing fields like response.data.items[0].id fails because the parser does not recognize the json structure. i have tried converting the string to an object using standard javascript methods within the snippet, but the sandbox environment restricts external libraries. here is the snippet logic i am using:

rest_proxy = getrestproxy()
rest_proxy.url = 'https://internal-api/v1/user/123'
rest_proxy.method = 'GET'
result = rest_proxy.invoke()
user_data = result.response
// expected: { 'data': { 'items': [ { 'id': '1' } ] } }
// actual: '{"data":{"items":[{"id":"1"}]}}'

the api returns 200 ok. the issue is strictly within the studio snippet execution context. how do i deserialize this string into a usable object or array within the snippet constraints?

If I remember correctly, getrestproxy in CXone Studio returns a stringified payload. You must parse it explicitly before accessing nested arrays. Use json.parse({{response.body}}) to convert the string to an object. Then, reference {{parsedResponse.data.items[0].id}} in subsequent actions. Direct indexing on the raw string will always fail.

The docs actually state that getrestproxy returns a string, so you must parse it explicitly before accessing nested arrays.

  1. Use json.parse({{response.body}}) to convert the payload.
  2. Reference {{parsedResponse.data.items[0].id}} in subsequent actions.

Direct indexing on the raw string will always fail.

The problem here is assuming the Assign action handles deserialization automatically. You must explicitly call json.parse({{response.body}}) in a prior Assign step to convert the payload before attempting array access.

It depends, but generally… the previous advice is correct. Studio treats response.body as a string. You must parse it first.

// Assign Action: Set parsedData
json.parse({{response.body}})

Then access {{parsedData.data.items[0].id}}. Works for me in NICE CXone.