-
-
Notifications
You must be signed in to change notification settings - Fork 150
Closed
Labels
Description
Currently, when a JsonProcessingException is thrown when parsing CSV with a missing closing quote, the reported location of the column where the error occurred is incorrect. For example,
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
import com.fasterxml.jackson.dataformat.csv.CsvParser;
import java.io.IOException;
import java.util.List;
public class Test {
public static void main(String[] args) throws IOException {
try (MappingIterator<List<String>> reader = new CsvMapper()
.readerForListOf(String.class)
.with(CsvParser.Feature.WRAP_AS_ARRAY)
.readValues("name,dob\n\"an invalid string,2020-05-01")) {
reader.readAll();
} catch (JsonProcessingException e) {
System.out.println("line number: " + e.getLocation().getLineNr());
System.out.println("column number: " + e.getLocation().getColumnNr());
}
}
}will output
line number: 2
column number: 68
The row number is correct, but the column number is not (there aren't even 68 characters in the entire CSV). I would expect the column number to be more like 30.