Details
-
Enhancement
-
Resolution: Unresolved
-
Minor
-
None
-
7.42.0.Final
-
None
-
NEW
-
NEW
Description
There are some behaviour differences in JSON payload type handling:
(A) JSONMarshaller.marshall() produces type with FQCN.
{ "org.kie.server.api.marshalling.objects.Pojo1" : { "desc" : "C", "pojo2" : { "org.kie.server.api.marshalling.objects.Pojo2" : { "desc2" : "B", "primitiveBoolean" : true, "pojo3" : { "org.kie.server.api.marshalling.objects.Pojo3" : { "desc3" : "A" } } } } } }
This is properly unmarshalled by JSONMarshaller.unmarshall(). And we can consider that this is the standard payload.
(B) Then, if we edit the above payload to use "simple class name" by removing packages,
{ "Pojo1" : { "desc" : "C", "pojo2" : { "Pojo2" : { "desc2" : "B", "primitiveBoolean" : true, "pojo3" : { "Pojo3" : { "desc3" : "A" } } } } } }
This is not properly unmarshalled. pojo1's fields are populated but pojo2's fields become 'null'.
(C) Btw, if we have a type (of "simple class name") only for a top level object,
{ "Pojo1" : { "desc" : "C", "pojo2" : { "desc2" : "B", "primitiveBoolean" : true, "pojo3" : { "desc3" : "A" } } } } } }
This is properly unmarshalled by JSONMarshaller.unmarshall().
-------------
So I conclude that "simple class name" works only for a top level object now.
The "simple class name" is handled by this part of JSONMarshaller$CustomObjectDeserializer.mapObject()
because JSONMarshaller$CustomObjectDeserializer.classes contains simple class names:
However, the mapObject() is called only for top level objects so nested objects are not properly handled.
I confirmed with Enrique that (A) is correct and (B) is not. (C) is for convenience.
So we don't take the behaviour difference as a bug. In other words, users should use (A) approach.
Enrique noted that he can provide a more uniform way to handle this. So I filed this JIRA.
FYI) You may use unit tests in this draft PR if useful:
https://github.com/kiegroup/droolsjbpm-integration/pull/2202