Support for invalid dates
Hi, My input CSV is not controlled by me. it is coming from some upstream server. I need to parse the CSV and there is fair chances for invalid values. Currently If there is any value which is not convertible to target datatype then i get JacksonException. There should be an option to ignore such values and move on to next value.
this is my exception.
at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67) at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1535) at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:910) at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate(StdDeserializer.java:523) at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate(StdDeserializer.java:466) at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateBasedDeserializer._parseDate(DateDeserializers.java:195) at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateDeserializer.deserialize(DateDeserializers.java:285) at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateDeserializer.deserialize(DateDeserializers.java:268) at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:287) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151) at com.fasterxml.jackson.databind.MappingIterator.nextValue(MappingIterator.java:277)
Please register a custom deserializer for such type. It can take whatever action necessary.
It would be a great help if you can share me an example. I am facing same issue for other data type BigDecimal too
Thanks.
@pramodbindal I am sure you can google for "jackson custom deserializers" -- there are many jackson tutorials in existence. In general, here:
https://github.com/FasterXML/jackson-docs
is a list of reported documentation, and I'd be happy to add links to other resources as well.
Deserializers are not format-specific wrt handling (that is, they are registered same way, have same API), so tutorials for json should work as examples.