Skip to content

StreamReadFeatures

Tatu Saloranta edited this page Sep 27, 2019 · 13 revisions

Jackson Streaming: StreamReadFeature

General

This set of features was added in Jackson 2.10, split off from earlier [JsonParser.Feature]. It contains features that are "dataformat agnostic", that is, affect all (or at least more than one) format backends, not just JSON backend.

Features

Settings can be divided in couple of loose categories, as follows.

Low-level I/O handling features

  • AUTO_CLOSE_SOURCE (default: true)
    • Feature that determines whether parser will automatically close underlying input source that is NOT owned by the parser. If disabled, calling application has to separately close the underlying InputStream and Reader instances used to create the parser.
      • If enabled, parser will handle closing, as long as parser itself gets closed: this happens when end-of-input is encountered, or parser is closed by a call to JsonParser.close().
    • Feature is enabled by default

Additional input validation

  • STRICT_DUPLICATE_DETECTION (default: false)
    • Feature that determines whether JsonParser will explicitly check that no duplicate (JSON) Object field names are encountered.
      • If enabled, parser will check all names within context and report duplicates by throwing a `JsonParseException```; if disabled, parser will not do such checking. Assumption in latter case is that caller takes care of handling duplicates at a higher level: data-binding, for example, has features to specify detection to be done there.
    • Note that enabling this feature will incur performance overhead due to having to store and check additional information: this typically adds 20-30% to execution time for basic parsing (but less time if measured at databind-level, due to other overhead)
  • IGNORE_UNDEFINED (default: false) (added in 2.6)
    • With formats that require Schema for parsing (like Avro, Protobuf, CSV), determines what happens if decoded encounters content that Schema has no definition for: if disabled, exception is thrown; if enabled, such content is quietly ignored.
    • Supported for: Avro, CSV
    • Note: setting has no effect on Avro since it has no mechanism for recognizing such "unknown" content -- there is no way for decoder to ignore such content and instead a decoding error is thrown (or data corruption occurs)
Clone this wiki locally