jackson-dataformat-csv icon indicating copy to clipboard operation
jackson-dataformat-csv copied to clipboard

Add SerializationFeature to Serialize Objects with toString() method

Open joseaio opened this issue 7 years ago • 1 comments

I can't find anything as this...

This Feature enables a default serialization (for Objects) calling their toString() method instead of launch error:

com.fasterxml.jackson.databind.JsonMappingException: CSV generator does not support Object values for properties (through reference chain: java.util.ArrayList[0]->***) at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:275) at com.fasterxml.jackson.dataformat.csv.CsvGenerator._reportMappingError(CsvGenerator.java:912) at com.fasterxml.jackson.dataformat.csv.CsvGenerator.writeStartObject(CsvGenerator.java:522) at com.fasterxml.jackson.core.base.GeneratorBase.writeStartObject(GeneratorBase.java:274) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:151)

joseaio avatar May 09 '18 13:05 joseaio

Thank you for suggesting this feature. It will be interesting to think how this could be implemented, given that this would either need to be configuration in jackson-databind to apply for some types, or, if here, how to implement it (since databind has no way to know specific rules are needed and will send tokens that CsvGenerator has to somehow reroute).

cowtowncoder avatar May 10 '18 21:05 cowtowncoder