I call aws lambda with json body. So json fields have a different name from POJO fields. So what I did was to add @JsonProperty to the fields to tell Jackson what names are in json. But for some reason, it seems that he does not recognize them, and all fields are zero. If I pass json with the same field names as POJO, it works. Here is my class:
public class Event implements Identifiable { @JsonProperty("distinct_id") private String distinctId; @JsonProperty("user_id") private Integer userId; @JsonDeserialize(using = LocalDateTimeDeserializer.class) @JsonSerialize(using = LocalDateTimeSerializer.class) private LocalDateTime eventDateTime;
If i pass
{"distinct_id":"123", "user_id":123, "dt":"2017-01-04T08:45:04+00:00"}
all fields are null and with differId, userId, eventDateTime it serializes normally, except that it also does not recognize my own serializers / deserializers, but this is actually the same problem.
My conclusion is that for some reason aws jackson doesn't work with annotations, but that doesn't make sense.
source share