Skip to content

[TCK Challenge] SerializersCustomizationCDITest assumes different behaviour than non-CDI SerializersCustomizationTest #344

@struberg

Description

@struberg

It seems that the deserialiser in SerializersCustomizationCDITest is expecting to see a START_OBJECT of the actual items instead of the actual current JsonValue event which is a START_ARRAY.

https://github.com/jakartaee/jsonb-api/blob/master/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/serializer/AnimalListDeserializerInjected.java#L44

This is different to the (imo correct) implementation in the deserialiser of the non-CDI TCK test which expects to see the START_ARRAY.

https://github.com/jakartaee/jsonb-api/blob/master/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalListDeserializer.java#L40

The reason why I think that START_ARRAY is correct is that only this way we can support more complex scenarios.
The current value to parse is

{ "animals" : [ { "type" : "cat", "cuddly" : true, "age" : 5, "furry" : true, "name" : "Garfield" , "weight" : 10.5}, { "type" : "dog", "barking" : true, "age" : 3, "furry" : false, "name" : "Milo", "weight" : 5.5}, { "type" : "animal", "age" : 6, "furry" : false, "name" : "Tweety", "weight" : 0.5} ] }

But imagine having a more complex JSON:

{
"animals": 
	{
	"size":3,
	"values": [ { "type" : "cat", "cuddly" : true, "age" : 5, "furry" : true, "name" : "Garfield" , "weight" : 10.5}, { "type" : "dog", "barking" : true, "age" : 3, "furry" : false, "name" : "Milo", "weight" : 5.5}, { "type" : "animal", "age" : 6, "furry" : false, "name" : "Tweety", "weight" : 0.5} ]
	}
}

For this case the jsonParser.next() should imo point at the START_OBJECT just before the 'size' attribute, right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions