I am running on JBoss
6.1.4
and was using Jackson
V1
. After changing my dependencies to reference version 2.4.4
(and changing all includes to fasterxml versions), it is like the @JsonSerialize
is being ignored. Instead of a String
(from the serializer), it is returning the class as JSON
that should have been serialized. Logging and System.out
inside the serializer is not showing up.
I made no changes to code other than changing includes to use fasterxml.
public class HiDateSerializer extends JsonSerializer<HiDate> {
@Override
public void serialize(final HiDate value, final JsonGenerator gen, final SerializerProvider sp) throws IOException, JsonProcessingException {
if (value == null || value.isNull()) {
gen.writeString("");
} else {
gen.writeString(value.fmt());
}
}
}
Then in my model class, I use annotation for on all HiDate
attributes:
@JsonSerialize(using = HiDateSerializer.class)
private HiDate dob;
Here is my dependency:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
What I was getting previously was either an empty string or a string with just the date. However, now I am getting a JSON
representation of the entire HiDate
class. It is as if the @JsonSerialize
is not being honored anymore.