2

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?

2

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.