Skip to content

JSTEP 7

Tatu Saloranta edited this page Jan 16, 2022 · 17 revisions

(Back to JSTEP page)

New DataTypeFeature configuration options (Jackson 2.x)

Related change issues: JSTEP-3 contains/-ed aspects of JsonNodeFeature

Author

Tatu Saloranta (@cowtowncoder)

Version history

  • 2022-01-16: The first draft version

Background

Over time, various XxxFeature on/off options have proven useful and popular with developers: they are easy to set, change and (for the most part), understand.

Original set of "Features" were configurable at Streaming API and Databind level, including:

  • JsonParser.Feature / JsonGenerator.Feature / JsonFactory.Feature for Streaming API
  • MapperFeature / SerializationFeature / DeserializationFeature for databind

and for Streaming API, further split of format-specific (often JSON-specific) vs. generic (across all or most formats) features, resulted in:

  • JsonParser.Feature split into generic StreamReadFeature and XxxReadFeature (like JsonReadFeature)
  • JsonGenerator.Feature split into generic StreamWriteFeature and XxxWriteFeature (like JsonWriteFeature).

But while this split allowed better support for Format-specific features (via Streaming API), there is no similar mechanism for more granular configuration for datatype-specific features. This has lead to inclusion of some "too [datatype] specific" features at databind level; for example:

  • DeserializationFeature.READ_ENUMS_USING_TO_STRING
  • DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS
  • SerializationFeature.WRITE_DATES_AS_TIMESTAMPS

Such configuration is against the idea that these Features should be cross-cutting across dataformats AND datatypes. But it is worth noting that there is need for such configuration, at some other granularity. This lead to the idea of "datatype-specific" features.

Challenges, choices

Clone this wiki locally