I define jackoson serializer and add it to java class as JsonDeserialize like this:
@JsonDeserialize(using = ReportFilterDeserializer.class)
The compiler give this error:
error: incompatible types: Class<ReportFilterDeserializer> cannot be converted to Class<? extends JsonDeserializer<?>>
@JsonDeserialize(using = ReportFilterDeserializer.class)
The def of the annotation is:
public Class<? extends JsonDeserializer<?>> using() default JsonDeserializer.None.class;
If I remove the generic atttibute from ReportFilterDeserializer its passed compilation. I dont understand why the complier complain.
class ReportFilterDeserializer<T> extends JsonDeserializer<ReportFilter<T>> {
@Override
public ReportFilter<T> deserialize(JsonParser jsonParser,DeserializationContext arg1) throws IOException,JsonProcessingException {
return null;
}
}
That certainly seems very odd. About the only thing I can think of is accidental mixing of Jackson 1.x and 2.x annotation vs classes (org.codehaus.jackson is 1.x, com.fasterxml.jackson 2.x).
Does behavior differ on different JDKs (7 vs 8, for example -- maybe Java 8 has issues?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With