Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "name:type" style Headers #474

Open
cowtowncoder opened this issue May 8, 2024 · 0 comments
Open

Add support for "name:type" style Headers #474

cowtowncoder opened this issue May 8, 2024 · 0 comments
Labels

Comments

@cowtowncoder
Copy link
Member

Currently use of Header row (and manual construction of CsvSchema) assume that headers only specify name of column position. But there exists usage, wherein header line contain type mappings too:

name:string,enabled:boolean, ...

It would be great to support this.

There is an immediate problem with "type" definition: as things are, only a very limited set of types is recognized for CsvColumn. But we could divide implementation into two main parts:

  1. Support mapping to existing small set of types (probably allowing case-insensitive type definition)
  2. Support configurability of extension types, by providing converters from String value into target types.

For (2) there is also additional step needed: whereas we could expose JsonToken values for:

  1. Strings
  2. Numbers
  3. Booleans
  4. nulls

everything else would need to be exposed as JsonToken.VALUE_EMBEDDED_OBJECT.
But if so, any and all types could be supported -- as long as jackson-databind deserializers (JsonDeserializer impelmentations) consider possibility of embedded type.

Doing above is not trivial, but would be a very powerful mechanism for customized binding from CSV data. Some amount of duplication would likely result (for Converters) but that seems acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant