-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Milestone
Description
Let's say I use JSON.std.beanFrom(MyBean.class, INPUT)
as stated in the docs and MyBean
has a Date
field. If the JSON being parsed has a numeric value for that data field, then everything works ok, but if the value is null
(for example "birthday":null
), then I end up with: com.fasterxml.jackson.jr.ob.JSONObjectException: Can not get long numeric value from JSON (to construct java.util.Date) from 'null'
.
This seems to be an arbitrary limitation caused by SimpleValueReader.read
having following block:
case SER_DATE:
return new Date(_fetchLong(p));
protected long _fetchLong(JsonParser p) throws IOException
{
JsonToken t = p.currentToken();
if (t == JsonToken.VALUE_NUMBER_INT) {
return p.getLongValue();
}
throw JSONObjectException.from(p, "Can not get long numeric value from JSON (to construct "
+_valueType.getName()+") from "+_tokenDesc(p, t));
}
Any reason to not improve on this, to return an actual null
value instead of throwing an exception? Conceptually at least, seam the right thing to do, especially since reading into a Map
(as opposed to POJO) works like that.
Metadata
Metadata
Assignees
Labels
No labels