How to use "List" or "Map" in JS?

Hello,

i have a simple List and a Map as input on my Camunda Service Task.

i get the input value with a nodejs skript:

var datamap = task.variables.get("datamap");
console.log(datamap);

var datalist = task.variables.get("data");
console.log(datalist);

I got this result in my console:

Map:
rO0ABXNyABFqYXZhLnV0aWwuVHJlZU1hcAzB9j4tJWrmAwABTAAKY29tcGFyYXRvcnQAFkxqYXZhL3V0aWwvQ29tcGFyYXRvcjt4cHB3BAAAAAJ0AARrZXkxdAAGVmFsdWUxdAAEa2V5MnQABnZhbHVlMng=

List:
rO0ABXNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAACdwQAAAACdAAtRWlnZW5zY2hhZnQgLyB0ZWNobmlzY2hlcyBNZXJrbWFsPWVpZ2Vuc2NoYWZ0dAAdUHJvZHVrdCBNb2RlbGw9cHJvZHVrdF9tb2RlbGx4


I see its a base64 String.
So i now want to make a foreach of the list and the map.

When i decode it its this:

Map:
�sr�java.util.TreeMap >-%j�L�
comparatort�Ljava/util/Comparator;xppw���t�key1t�Value1t�key2t�value2x

List:
�sr�java.util.ArrayListxa�I�sizexp���w���t�-Eigenschaft / technisches Merkmal=eigenschaftt�Produkt Modell=produkt_modellx


How i can make a foreach to see this result in my console:

Map:
key1: value1
key2: value2

List:
Eigenschaft / technisches Merkmal=eigenschaftt
Produkt Modell=produkt_modell


I am unable to dot it with JS. (in my nodejs Skript)
How i can do it??

Hi,

You must ensure, that the variables are serialized as JSON.
For this purpose, Camunda provides a library called Camunda Spin.
The following references may help you with the configuration:

1 Like