How do I handle a BytesValue process variable via JavaScript?

We store large JSON values via the Java API as BytesValue to avoid problems that occured with too large historic variable values when storing strings.

The Variable is accessible from a script task where we want to use javascript to retrieve the original JSON value. How can we achieve this?

iif it is external task worker, variable value can be passed as camunda native json object like this:
Input parameter type script:

and can be acessed in js worker like:
params.data[0].dt
params.data[0].ImageName
params.table

I’m not quite sure if my question was unclear or if I don’t get what you’re proposing with your answer, but I don’t see how it helps with my problem.

I stored a process variable as BytesValue via java API.
I want to work with this existing process variable inside a javascript ScripTask.
I can access the variable inside the ScriptTask, as expected.
But I am not able to convert the variable to a JSON object inside the script.
What I’m looking for is a way to convert it into a JSON object I can use inside the ScriptTask, so basically:

// get json object from processVar
var json = retrieveJsonFromBytesValue(bytesValue); // where bytesValue is an existing processVariable

// do stuff with the json object
var someJsonArray =  json.prop("value").elements();
...