eclipse-ee4j / eclipse-ee4j/yasson

Custom Deserializer with Generics

Open
#229 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
218
Forks
109
Avg merge
1d 5h
Merged PRs (30d)
9

Description

Hi all,
I ‘m using wildfly 14 with jersey 2.27 and java 11.

Previously I used Jackson and now I’m trying to substitute it with yasson.
I’m using the yasson version provided by wildfly:

org.eclipse
yasson
1.0.1
provided

I have the following deserializer:
`public class GenericDeserializer implements JsonbDeserializer> {`

declared on Generic class
`@JsonbTypeDeserializer(GenericDeserializer.class)`
`public class Generic {`

and a rest service that for example use the Generic class in this way:

`@POST`
`@Path("/items/mass/{appName}/{id}")`
`@Consumes(MediaType.APPLICATION_JSON)`
`@Produces(MediaType.APPLICATION_JSON)`
`public Response mass(@PathParam("appName") String applicationName, @PathParam("id") Long id, GenericsearchRequest)`

of course the class BaseFilterDto is an example, but I can pass each type I want, so I cannot know which it is at deserializer creation time.

I tested the service but the deserializer is not called.

Is there a "clean" way to resolve this?
I have found a way using reflection but of course must not be the right one

Contributor guide

Open the contributing guide

Research direction

Start with the GenericDeserializer and Generic class declarations, then reproduce the REST method using Generic on WildFly 14 with Yasson 1.0.1. Trace whether the @JsonbTypeDeserializer annotation is discovered for the generic request type; done means the behavior is explained and a supported resolution or clearly documented limitation is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.