serialize/deserialize java 8 java.time with Jackson JSON mapper

后端 未结 17 1169
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 15:56

How do I use Jackson JSON mapper with Java 8 LocalDateTime?

org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple t

17条回答
  •  失恋的感觉
    2020-11-22 16:42

    If any one having problem while using SpringBoot here is how I fixed the issue without adding new dependency.

    In Spring 2.1.3 Jackson expects date string 2019-05-21T07:37:11.000 in this yyyy-MM-dd HH:mm:ss.SSS format to de-serialize in LocalDateTime. Make sure date string separates the date and time with T not with space. seconds (ss) and milliseconds(SSS) could be ommitted.

    @JsonProperty("last_charge_date")
    public LocalDateTime lastChargeDate;
    

提交回复
热议问题