I'm using Spring Boot 1.5.6 with Jackson 2.8.8. When deserializing the answer of a REST call, Jackson fails with the following exception:
JSON parse error: Can not construct instance of org.joda.time.DateTime: no String-argument constructor/factory method to deserialize from String value ('2018-03-19T12:05:21.885+01:00')
It's true there is no String constructor, only an Object constructor in the DateTime
object.
I included the jackson-datatype-joda
dependency in my build.gradle file. These are the respective lines from the build.gradle:
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: jacksonVersion
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5', version: jacksonVersion
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-joda', version: jacksonVersion
Is there any additional configuration I need to do?
PS: If I put the date String into a new DateTime("2018-03-19T12:05:21.885+01:00")
it works fine.
Any ideas? Cheers!
Did you register the JodaModule
module in your ObjectMapper
?
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JodaModule());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With