I am using Dropwizard 0.8.4 and jackson-datatype-jsr310.
a) Would like to serialise my LocalDateTime to JSON output as DateTimeFormatter.ISO_INSTANT but could not find any clean way to do that (without implementing custom serialising classes), shouldn't this be very standard thing to do with simple annotations?
Currently my code works with:
@JsonProperty
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss'Z'")
@JsonSerialize(using = LocalDateTimeSerializer.class)
public LocalDateTime getTime() {
...
}
but that pattern isn't really same as ISO_INSTANT, and as I debugged it a bit, ISO_INSTANT cannot even be presented by a String-pattern.
b) Would I be better off using Joda-Time, that seems to be supported by Dropwizard by default?
c) Is there way to skip serialising Java-field into JSON based on the value (boolean being false)? I tried @JsonFilter and SimpleBeanPropertyFilter but didn't get it to work, and it seems to be deprecated as well. Also @JsonProperty(defaultValue...) didn't seem to work either.