I’m having some difficulty trying to get Jackson to serialize/deserialize JSON date strings sent from an ASP.NET service. The string is in the following format:
/Date(1234567890123)/
A simple example of the type of output I get from the server is like the following:
{
"name" : "Bob Marley",
"birthdate" : "/Date(1234567890123)/"
}
How can I get Jackson to convert the date to a Java date object? Is there a way to do it without having to write a custom serializer/deserializer?
Your best bet is to write a custom deserializer. Or alternatively, to store the string representation of the date in your bean, but provide an alternative getter that converts the string to a date using a DateFormat instance. The first option is cleaner and more efficient.
See question previously asked here on SO.