filmov
tv
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.t

Показать описание
I upgraded my java project to jdk17, spring 6.1 and springboot 3.3
I am getting
error while fixing my junits
Reproducible code -
public static ObjectMapper getObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper;
}
public static T T getJsonFixtureFromString(String jsonString, Class T clazz) {
return getObjectMapper().readValue(jsonString, clazz);
}
@Test
public void myTest(){
String s = "{\"name\":\"Evening Restriction\",\"restrictions\":[{\"starttime\":\"7:45PM\",\"endtime\":\"8:15PM\"}]}"
RestrictProfileDTO dto = getJsonFixtureFromString(s, RestrictProfileDTO.class);
}
public static ObjectMapper getObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper;
}
public static T T getJsonFixtureFromString(String jsonString, Class T clazz) {
return getObjectMapper().readValue(jsonString, clazz);
}
@Test
public void myTest(){
String s = "{\"name\":\"Evening Restriction\",\"restrictions\":[{\"starttime\":\"7:45PM\",\"endtime\":\"8:15PM\"}]}"
RestrictProfileDTO dto = getJsonFixtureFromString(s, RestrictProfileDTO.class);
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RestrictProfileDTO {
@JsonProperty(value = "name")
private String name;
@JsonProperty(value = "restrictions")
private List RestrictionDTO restrictions;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RestrictionDTO {
@JsonProperty(value = "starttime")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "h:mma")
private LocalTime startTime;
@JsonProperty(value = "endtime")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "h:mma")
private LocalTime endTime;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RestrictProfileDTO {
@JsonProperty(valSource of the question:
Question and source license information: