I have an object stored in a String. One of the object's fields is a LocalDate.
"from": {
"year": 1000,
"month": "JANUARY",
"era": "CE",
"dayOfMonth": 1,
"dayOfWeek": "WEDNESDAY",
"dayOfYear": 1,
"leapYear": false,
"monthValue": 1,
"chronology": {
"calendarType": "iso8601",
"id": "ISO"
}
}
How should I go about converting this json to a format that can be used for deserializing it?
The following code
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
ObjectMapper om = new ObjectMapper();
om.registerModule(new JavaTimeModule());
MyCustomObject obj = om.readValue(json, MyCustomObject.class); //error
causes this Exception:
com.fasterxml.jackson.databind.JsonMappingException: Unexpected token (START_OBJECT), expected VALUE_STRING: Expected array or string.
Here's the MyCustomObject class which I use as MyCustomObject<LocalDate>
public class MyCustomObject<T> {
private T from;
private T to;
public MyCustomObject() {
}
public T getFrom() {
return this.from;
}
public void setFrom(T from) {
this.from = from;
}
public T getTo() {
return this.to;
}
public void setTo(T to) {
this.to = to;
}
}