-
-
Notifications
You must be signed in to change notification settings - Fork 795
StreamReadFeatures
Tatu Saloranta edited this page Sep 27, 2019
·
14 revisions
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.
Settings can be divided in couple of loose categories, as follows.
-
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
andReader
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()
.
- 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
- Feature is enabled by default
- 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
-
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)
- Feature that determines whether
-
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)