Questions tagged [jackson-dataformat-csv]

Jackson extension for adding support for reading and writing CSV formatted data

Jackson data format module for reading and writing CSV encoded data, either as "raw" data (sequence of String arrays), or via data binding to/from Java Objects (POJOs).

50 questions
7
votes
1 answer

Parsing double quote from csv using jackson-dataformat-csv

I have a csv that contains the…
prettyvoid
  • 3,446
  • 6
  • 36
  • 60
7
votes
3 answers

jackson-dataformat-csv does not ignore unknown properties

Trying to parse .csv file with jackson-dataformat-csv. File contains a lot of columns not relevant for my program. Tried to use @JsonIgnoreProperties(ignoreUnknown = true) on my data class, and…
mbaranauskas
  • 435
  • 1
  • 4
  • 8
6
votes
4 answers

Jackson ObjectWriter only writes first entry from stream

I want to create a Spring Boot controller which creates a CSV file using data from a stream. I use Jackson CSV (jackson-dataformat-csv 2.12.1) to write the data stream from the DB to a StreamingResponseBody. To keep it simple, I replaced the actual…
Peter
  • 1,679
  • 2
  • 31
  • 60
6
votes
2 answers

jackson-dataformat-csv: Mapping number value without POJO

I'm trying to parse a CSV file using jackson-dataformat-csv and I want to map the numeric column to the Number java type. CsvSchema schema = CsvSchema.builder().setUseHeader(true) .addColumn("firstName", CsvSchema.ColumnType.STRING) …
Igor Luzhanov
  • 780
  • 1
  • 7
  • 14
4
votes
2 answers

Jackson how map one Pojo field to 2 (json) fields (same content, different name)

I use Jackson to serialise POJOs into CSV. Now we need to change the naming for certain fields to snake_case. This is easily done by @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class). For compatibility reasons we need some of the renamed…
dermoritz
  • 12,519
  • 25
  • 97
  • 185
3
votes
1 answer

Jackson CsvMapper reads only the first line

I want to read csv file to List of strings. I also want it to trim whitespaces and allow trailing comma. My csv file looks like this: abcdefghijklmno , pqrstuwzabcdefh, ijklmnopqrstuwyz, zabcdefghijklmopqr, And when I try to parse it using my…
Clyde Barrow
  • 1,924
  • 8
  • 30
  • 60
3
votes
3 answers

Ignore Specific Columns Parsing a CSV File with Jackson CSV

My problem is that I need to parse CSV files with arbitrary columns/order into a known domain POJO (say Person). I can identify which columns that I need to process, ignoring the rest. The option CsvParser.Feature.IGNORE_TRAILING_UNMAPPABLE" seemed…
tkofford
  • 97
  • 2
  • 12
3
votes
1 answer

Configure CsvMapper to Inspect Each Value Written

I am using jackson-dataformat-csv to export a POJO collection to CSV as follows: CsvSchema.Builder schemaBuilder = CsvSchema.builder() .addColumn("id") .addColumn("name") etc... CsvSchema schema = schemaBuilder.build().withHeader(); CsvMapper…
Curt Williams
  • 163
  • 2
  • 7
3
votes
1 answer

Parsing CSV into a POJO list with Jackson CSV

I have a string, which contains CSV data and would like to parse this into a list of POJOs. How can I do this with Jackson CSV? Bonus: How can I make it so that it uses CSV headers? My two unsuccessful attempts: CsvMapper mapper = new…
Adam Beddoe
  • 153
  • 2
  • 10
3
votes
2 answers

Jackson CsvMapper fails to correctly deserialize to POJO despite schema configuration

For some reason despite configuring a FasterXML Jackson CSV mapper to create a POJO-based schema, it insists that no suitable configuration has been provided. I get the following exception: com.fasterxml.jackson.databind.JsonMappingException: No…
Sinker
  • 576
  • 1
  • 7
  • 21
3
votes
3 answers

Writing generic POJO to CSV transformer

My use case was to write a generic CSV transformer, which should be able to convert any Java POJO to CSV string. My Implementation : public List convertToString(List objectList) { List stringList = new…
3
votes
2 answers

How do I serialize & deserialize CSV properly?

I've been trying to serialize an object to a CSV String but the object contains a List and @JsonUnwrapped doesn't work on List objects. Expected sample output: color,part.name\n red,gearbox\n red,door\n red,bumper Actual…
Hooli
  • 1,135
  • 3
  • 19
  • 46
2
votes
1 answer

Parsing double quote with new line from CSV using jackson-dataformat-csv

I have the following CSV format: id,name,description,age 23,Anna,"Self-made Chef Shoemaker",23 The double-quotes are only present if the attribute is multi-line. While I am already been able to read the normal CSV correctly: @Bean public CsvMapper…
Shubham A.
  • 2,446
  • 4
  • 36
  • 68
2
votes
3 answers

Is there a way to convert a String to a Java type using Jackson and/or one of its associated libraries (csv, json, etc.)

Is there a mechanism to apply a standard set of checks to detect and then transform a String to the detected type, using one of Jackson's standard text related libs (csv, json, or even jackson-core)? I can imagine using it along with a label…
Gary Sharpe
  • 2,369
  • 8
  • 30
  • 51
2
votes
2 answers

Failing with InvalidFormatException when using date fields with jackson-dataformat-csv

I am trying to use the CSVMapper utility from jackson-dataformat-csv to parse a CSV file and create POJO records to insert to mysql database. When doing so, I am facing issues if a date information is present as one of the columns in the CSV to be…
svijay.aug12
  • 531
  • 3
  • 13
  • 32
1
2 3 4