I get an exception when trying to deserialize a JSON string containing date strings in POJO using Joda.
I am using Jackson2 with Spring and Robospice.
I get the following exception:
Failed to read JSON: cannot create value of type [simple type, class org.joda.time.DateTime] from String value ('2014-07-25T00: 00: 00'); no constructor String / factory method
Here is the code I currently have:
MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); mappingJackson2HttpMessageConverter.getObjectMapper().registerModule(new JodaModule()); msgConverters.add(mappingJackson2HttpMessageConverter); restTemplate.setMessageConverters(msgConverters); HttpEntity<?> httpEntity = new HttpEntity<Object>(headers); final ResponseEntity<HolidayList> responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity,HolidayList.class);
POJO fields are defined as follows:
private DateTime departureDate;
This worked for me in Jackson1 ... but it doesn't seem to work in Jackson2.
jackson spring-android jodatime
Chris nevill
source share