Given a simple entity class like this
public class User
{
@JsonProperty
public Calendar createdOn;
@JsonProperty
public String name;
}
Is there a way for me to hook into the jackson streaming API to custom deserialize ONLY the createdOn field? If there's not, then would something like this be possible in the future?
public class User
{
@JsonProperty
@JsonConverter(MyCustomCalendarConverter.class)
public Calendar createdOn;
@JsonProperty
public String name;
}
It appears that I could custom deserialize the entire entity. I'm just curious if there is a way to customize the deserialization just a field at a time in order to, for example, custom parse a particular date format, or read an array of values into a custom entity, etc. while letting Jackson deserialize the rest of the entity normally.
解決方案
You can define custom serialize a specific field using @JsonSerialize:
@JsonSerialize(using=MuCustomCalendarConverter.class)