DucanoidYoung
DucanoidYoung

Reputation: 83

Jackson csv - use semicolon(;) to deserialize as a string list

I'm using jackson csv to parse a csv as pojo

ID,requestId,requestSource,documentIds,trackingIds
documentIds,123456,CLAIMS,123456;223456,

->

@Data
@NoArgsConstructor
@JacksonXmlRootElement(localName = "triggerDocumentExport",namespace = Connection.NAMESPACE_CAS)
public class TriggerDocumentExport {
    private Wrapper in;

    public TriggerDocumentExport(Wrapper in){this.in = in;}

    @Data
    public static class Wrapper{
        private String requestId,
                requestSource;

        private List<String> documentIds,
                trackingIds;
    }
}

I want documentIds to be parsed as a List<String>, with default ArrayElementSeparator(which is ;)

but it keeps parsing it as a single string "123456;223456"

without DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, I got an exception

with the configuration, I got a List with only one element "123456;223456"

enter image description here If I don't make mistake, should jackson csv support semicolon-seperated list by default?Or there's something I've misunderstood.

Upvotes: 1

Views: 809

Answers (0)

Related Questions