I have a webservice which prints "null" as a string for any property instead of null literal. It does that for almost all data types(String or Date). For example, in ideal case it returns
{
"item" : {
"title": "Some title",
"expires": "2014-11-02 00:00:00"
}
}
But sometimes it returns:
{
"item" : {
"title": "null",
"expires": "2014-11-02 00:00:00"
}
}
Which makes the title property value as "null" instead of setting it to null. Or sometime this:
{
"item" : {
"title": "Some title",
"expires": "null"
}
}
Which makes the deserialization fail because the dateformat does not match. How can I configure objectmapper or annotate my model classes to resolve these problems during deserialization?
My model class looks like:
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Item {
public String title;
@JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
public Date expires;
}
It's an android app so I have no control over the webservice. Thanks in advance