Skip to content

Use CsvMapper with ObjectMapper in the same Spring projectΒ #489

@abccbaandy

Description

@abccbaandy

I am trying jackson CSV feature, but I have some question:

  1. Seems CsvMapper extends ObjectMapper.
    I think it's not possible define CsvMapper as Bean without touch Spring ObjectMapper bean?

  2. CSV feature reuse many JSON annotation, is it possible have different config for CSV/JSON in the same POJO?
    For example:
    If I want ignore a field in CSV only, I put @JsonIgnore on the field.
    But it will affect ObjectMapper process that POJO too.

  3. Use the same config for both CSV and Json.
    Mainly for have same behave for convert Java 8 time, locale...etc
    But I don't find something like setConfig(json.getConfig()), so I try to config one by one by myself.

        csvMapper.findAndRegisterModules();
        csvMapper.setConfig(jacksonObjectMapper.getSerializationConfig());
        csvMapper.setConfig(jacksonObjectMapper.getDeserializationConfig());

        //do other config in CSV only

Is this enough?
I don't find any issue for now though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions