Rest engine JSON deserialization

Hi, I’m using rest-engine to initiate simple process instance with variables inlcuding a collection (see example). My purpose is to iterate the collection with decision task. I’m using sequential multi-instance decision task. The problem is that with “objectTypeName”: “SpinJsonNode” I get exception Cause: Cannot deserialize object in variable ‘cars’: SPIN/JACKSON-JSON-01007 and with “objectTypeName”: “java.util.ArrayList” an insternal server error "Unable to convert value ‘{make=Ford, model=escort}’ of type ‘class java.util.LinkedHashMap’ to type ‘class java.lang.String’ in expression ‘“escort”’

{
    "businessKey": "Key1",
    "withVariablesInReturn": true,
    "variables":
    {
        "name":
        {
            "type": "String",
            "value": "John Doe"
        },
        
        "cars":
        {
            "type": "Object",
            "value": "[{\"make\":\"Ford\",\"model\":\"escort\"},{\"make\":\"Ford\",\"model\":\"fiesta\"]",
            "valueInfo":
            {
                "objectTypeName": "java.util.ArrayList",
                "serializationDataFormat": "application/json"
            }
        }
    }
}

What would be the correct way to deserialize the collection? I’ve tried also to create DTO-class but nothing seems to work.

1 Like

Resolved this by myself. The json payload above was correct, but misunderstood what is passed to the decision task. To the Collection field you should describe the name of the collection variable (in this case cars) and the Element variable describes the name of the one element of that collection (e.g. car) and the multi instance task is iterating the whole array of car-elements one by one. On DMD-file you should refer - at this case - to car.make or car.model. Afterwards this feels so obvious :slight_smile:

While multi instance decision task is iterating the whole array, the decision task will overwrite the result each time if the Completion Condition is not set, but that is another topic.