apache / incubator-kie-kogito-runtimes

Kogito Runtimes - Kogito is a cloud-native business automation technology for building cloud-ready business applications.
http://kogito.kie.org
Apache License 2.0
542 stars 209 forks source link

Json Merge procedure, empty object with array should result in array, not array embedded within response #3629

Closed fjtirado closed 2 months ago

fjtirado commented 2 months ago

Description

if a null target is merged with an array or non object source, the result is an array or not object, but if an empty object target is merged with array source, the result is an object with a property "response" containing the array or the non object source. After some thoughts with @ricardozanini, we feel is more natural to set the model to the array or the non object. That means that the workflow model might not be an object (which is actually more inclusive). if later on we try to merge the array with an object returned by another operation, that object will be added to the array. if we try to merge a non object non array node with an object, the non object value will be stored in "_target" property of the returned object. If a non object is merger with a non object, the model becomes the second non object. Finally, if a non object is merged into a non empty object, it is stored in "response" property. In general users should be proactive indicating the result of the merge through ActionDataFilter, here we are discussing defaults in case nothing is specified.

Note that this is a backward compatibility breaker. Workflows than inject a string before returnes {"response":"Hello World"}. now they will be returning just "Hello World"

Implementation ideas

Add target.isEmpty check