我无法反序列化 LocalDate
:
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate dateOfBirth;
@Test
public void test() throws IOException {
ObjectMapper ob = new ObjectMapper();
ob.registerModule(new JavaTimeModule());
ob.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
String json = "{\n"
+ " \"year\": 2021,\n"
+ " \"month\": \"JUNE\",\n"
+ " \"era\": \"CE\",\n"
+ " \"dayOfYear\": 155,\n"
+ " \"dayOfWeek\": \"FRIDAY\",\n"
+ " \"leapYear\": false,\n"
+ " \"dayOfMonth\": 4,\n"
+ " \"monthValue\": 6,\n"
+ " \"chronology\":\n"
+ " {\n"
+ " \"id\": \"ISO\",\n"
+ " \"calendarType\": \"iso8601\"\n"
+ " }\n"
+ " }";
dateOfBirth =
ob.readValue(json, LocalDate.class);
System.out.println(dateOfBirth);
}
暂无答案!
目前还没有任何答案,快来回答吧!