I'm serializing some java.util.Dates within a Map. The dates are serialized into Longs (Jackson writes the Long
value of the Date
instance to the JSON string), however, they're not being de-serialized back to Date
instances, but as Long
instances.
I'd like Jackson to de-serialize the dates back to Date objects (rather than formatted Strings or Longs), how can I achieve this?
Map<String, Comparable<?>> change = new HashMap<String, Comparable<?>>();
change.put("DESCRIPTION", "LIBOR");
change.put("RATE", "1.8");
change.put("DATE", Util.newDate(2009, 7, 1)); // Returns a java.util.Date
Produces
{"DESCRIPTION":"LIBOR"},{"RATE":"1.8"},{"DATE":1246402800000}, ... }
Which is okay. However, the date String is deserialized (inflated) back into an instance of java.lang.Long
, when I want it to be an instance of java.util.Date
- which is what it started as.
i.e. Map change
now contains three entries; Description as a String
, Rate as a Float
and Date as a Long
.