Reputation: 95
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?
Upvotes: 2
Views: 1469
Reputation: 5794
I think the ASP.NET service is producing a strange value for the date and would change that if I could. If I cannot, then writing a customer deserializer is the way to go.
Upvotes: 1
Reputation: 80593
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.
Upvotes: 3