Skip to content

Cannot serialize a list of beans into CSV format using JacksonRepresentation #928

Open
@thboileau

Description

@thboileau

as reported here http://stackoverflow.com/questions/24569318/writing-multi-line-csv-with-jacksonrepresentation, the current JacksonRepresentation does not take into account correctly the serialization of collection of beans to CSV format.
The objectWriter is not correctly set, and in addition it can't be correctly overriden by specifying the csv schema.

As workaround:

rep = new JacksonRepresentation<MyBean[]>(MediaType.TEXT_CSV, tab) {
    @Override
    protected ObjectWriter createObjectWriter() {
        CsvMapper csvMapper = (CsvMapper) getObjectMapper();
        CsvSchema csvSchema = csvMapper.schemaFor(MyBean.class);
        ObjectWriter result = csvMapper.writer(csvSchema);
        return result;
    }
};

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions