Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit ff1626c

Browse files
committed
Add a mention of configurable CsvSchema properties
1 parent d4962a6 commit ff1626c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

README.md

+24-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To use this extension on Maven-based projects, use following dependency:
1919
<dependency>
2020
<groupId>com.fasterxml.jackson.dataformat</groupId>
2121
<artifactId>jackson-dataformat-csv</artifactId>
22-
<version>2.4.0</version>
22+
<version>2.5.3</version>
2323
</dependency>
2424
```
2525

@@ -119,7 +119,7 @@ while (it.hasNext()) {
119119
}
120120
```
121121

122-
### With column names from first row
122+
## With column names from first row
123123

124124
But if you want a "data as Map" approach, with data that has expected column names as the first row,
125125
followed by data rows, you can iterate over entries quite conveniently as well.
@@ -169,6 +169,28 @@ This means that using earlier CSV data example, parser would instead expose it s
169169

170170
This is useful if functionality expects a single ("JSON") Array; this was the case for example when using `ObjectReader.readValues()` functionality.
171171

172+
## Configuring `CsvSchema`
173+
174+
Besides defining how CSV columns are mapped to and from Java Object properties, `CsvSchema` also
175+
defines low-level encoding details. These are details be changed by using various `withXxx()` and
176+
`withoutXxx` methods (or through associated `CsvSchema.Builder` object); for example:
177+
178+
```java
179+
CsvSchema schema = mapper.schemaFor(Pojo.class);
180+
// let's do pipe-delimited, not comma-delimited
181+
schema = schema.withColumnSeparator('|')
182+
// and write Java nulls as "NULL" (instead of empty string)
183+
.withNullValue("NULL")
184+
// and let's NOT allow escaping with backslash ('\')
185+
.withoutEscapaChar()
186+
;
187+
ObjectReader r = mapper.readerFor(Pojo.class).with(schema);
188+
Pojo value = r.readValue(csvInput);
189+
```
190+
191+
192+
For full description of all configurability, please see [../wiki/CsvSchema].
193+
172194
# Documentation
173195

174196
* [Wiki](../../wiki) (includes javadocs)

0 commit comments

Comments
 (0)