Skip to content

JsonParser.Feature.EMPTY_STRING_AS_NULL does not work when text is parsed as String[] #222

@wkwkhautbois

Description

@wkwkhautbois

CsvParser.Feature.EMPTY_STRING_AS_NULL not works when csv is parsed String[].
On the other hand, the feature is valid when csv is parsed as Object[].

String csv = "Grace,,Hopper";

CsvMapper csvMapper = CsvMapper.builder()
        .enable(CsvParser.Feature.EMPTY_STRING_AS_NULL)
        .enable(CsvParser.Feature.WRAP_AS_ARRAY)
        .build();

MappingIterator<Object[]> it1 =  csvMapper.readerFor(Object[].class).readValues(csv);
it1.hasNext();
Object[] array1= it1.next();

MappingIterator<String[]> it2 =  csvMapper.readerFor(String[].class).readValues(csv);
it2.hasNext();
String[] array2= it2.next();

System.out.println(Arrays.toString(array1));    // [Grace, null, Hopper]
System.out.println(Arrays.toString(array2));    // [Grace, , Hopper]      array2[1] is not null, but empty string ""

This is strange behavior and both case should parsed as null, I think.
Is this a bug?

jackson v.2.11.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions