Issue with Converting java.util.List to JSON in Camunda BPM Script Task

Form Id variable at the time of process instance(start event) variable data type is Object(Java.util.list)
When we are setting the value of the variable in javascript task we are getting the error that text char is grater than 4000.
(var insertList = execution.getVariable(‘insertList’); )
When we try to JSON.parse(variable) we are getting errors in script task.
We were not able to use spin S(variable)

How can we convert that input variable to a JSON object hence we can iterate it and do the required operations in camunda script task?

need a help @Niall @Ingo_Richtsmeier @WilliamR.Alves

Hello my friend!

If you look for the variable with

var insertList = execution.getVariable("insertList");

After this, transform the variable into a Json String as follows:

var jsonString = JSON.stringify(insertList);

And finally parse the Json string to a Json object:

JSON.parse(jsonString);

Doesn’t work for you?

William Robert Alves

Hi friend!.

We have list size of 20 elements.

When using → var insertList = execution.getVariable(‘insertList’); we are getting error in Camunda that varchar(4000) too long.

The size which we are sending is around 10000.

Thanks
Santosh.