Skip to content

JsonParser Features

Tatu Saloranta edited this page Nov 18, 2013 · 10 revisions

Jackson Streaming on/off features: JsonParser.Feature

Jackson Streaming API has a set of on/off features that change the way streaming parsing is done. Features can be directly enabled/disabled on JsonParser instances, but more commonly default values are changed on JsonFactory instances. For example:

JsonFactory f = new JsonFactory();
f.enable(JsonParser.Feature.ALLOW_COMMENTS);
f.disable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
JsonParser p = f.createParser(jsonSource);
p.enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION);

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

Low-level I/O handling features:

  • AUTO_CLOSE_SOURCE (default: true)

Support for non-standard data format constructs

  • ALLOW_COMMENTS (default: false)
  • ALLOW_YAML_COMMENTS (default: false)
  • ALLOW_UNQUOTED_FIELD_NAMES (default: false)
  • ALLOW_SINGLE_QUOTES (default: false)
  • ALLOW_UNQUOTED_CONTROL_CHARS (default: false)
  • ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER (default: false)
  • ALLOW_NUMERIC_LEADING_ZEROS (default: false)
  • ALLOW_NON_NUMERIC_NUMBERS (default: false)

Additional input validation

  • ** STRICT_DUPLICATE_DETECTION** (default: false) (added in 2.3)
Clone this wiki locally