我正在尝试在Camunda的Process中合并Javascript类型的Script Task中的两个数组。这是我的脚本:
var arr1 = execution.getVariableTyped("arr1", true);
var arr2 = execution.getVariableTyped("arr2", true);
var merged = [];
for (var i1 in arr1) {
var found = false;
for (var i2 in merged) {
if (arr1[i1].id == merged[i2].id) {
found = true;
break;
}
}
if (!found) {
merged.push(arr1[i1]);
}
}
for (var i1 in arr2) {
var found = false;
for (var i2 in merged) {
if (arr2[i1].id == merged[i2].id) {
found = true;
break;
}
}
if (!found) {
merged.push(arr2[i1]);
}
}
execution.setVariable("arr1", merged);
execution.removeVariable("arr2");
执行上述脚本时,它会引发异常:
无法完成任务 b4fb856a-6a92-11e5-9774-005056c00008:无法序列化变量“arr1”中的对象:SPIN/JACKSON-JSON-01009 无法将对象“jdk.nashorn.internal.objects.NativeArray@5ff42b74”映射到 json 节点
这是为什么?有什么问题,我该如何解决?反正有调试这样的脚本吗?