Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Support for invalid dates #153

Open
pramodbindal opened this issue Sep 12, 2017 · 3 comments
Open

Support for invalid dates #153

pramodbindal opened this issue Sep 12, 2017 · 3 comments

Comments

@pramodbindal
Copy link

pramodbindal commented Sep 12, 2017

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)

@cowtowncoder
Copy link
Member

Please register a custom deserializer for such type. It can take whatever action necessary.

@pramodbindal
Copy link
Author

pramodbindal commented Sep 13, 2017

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.

@cowtowncoder
Copy link
Member

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants