I tried using a custom serializer but it seems to never even go there when the value is null, so it never does my code to print empty string:
@JsonSerialize(using = NullDateSerializer.class)
public Timestamp getFinalizedDate() {
return finalizedDate;
}
--
public class NullDateSerializer extends JsonSerializer<Date> {
@Override
public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
if (value == null)
jgen.writeString("");
else
jgen.writeNumber(value.getTime());
}
}
So what do I do then?
I found several threads on writing nulls across the whole app using some ObjectMapper, and though I prefer to do it explicitly like using @JsonSerialize I tried that but it did not even work. I guess the old solutions dont work anymore. Regardless, I want to do it with a @JsonSerialize.
Using jackson 1.9.3 spring 3.2.2