-
-
Notifications
You must be signed in to change notification settings - Fork 795
JsonWriteFeatures
Tatu Saloranta edited this page Sep 27, 2019
·
4 revisions
This set of features was added in Jackson 2.10, split off from earlier JsonParser.Feature. It contains features that are only relevant and usable on JSON backend.
Note: with 2.10 and later 2.x version there is overlap between new and old features: Jackson will keep "same" settings in sync so you can whichever; but recommendation is to use newer set of features to ease migration to 3.0.
Settings can be divided in couple of loose categories, as follows.
-
ESCAPE_NON_ASCII (default: false)
- Feature that specifies that all characters beyond 7-bit ASCII range (i.e. code points of 128 and above) need to be output using backslash-escape.
- Maps to
JsonGenerator.Feature.ESCAPE_NON_ASCII
-
QUOTE_FIELD_NAMES (default: true)
- Feature that determines whether JSON Object field names are quoted using double-quotes, as specified by JSON specification or not. Ability to disable quoting was added to support use cases where they are not usually expected, which most commonly occurs when used straight from Javascript.
- Maps to
JsonGenerator.Feature.QUOTE_FIELD_NAMES
-
WRITE_NAN_AS_STRINGS (default: true)
- Feature that determines whether "NaN" ("not a number", that is, not real number) float/double values are output as JSON strings.
- The values checked are
Double.Nan
,Double.POSITIVE_INFINITY
andDouble.NEGATIVE_INIFINTY
(and associatedFloat
values). - If feature is disabled, these numbers are still output using associated literal values, resulting in non-conforming output.
- Maps to
JsonGenerator.Feature.QUOTE_NON_NUMERIC_NUMBERS
-
WRITE_NUMBERS_AS_STRINGS (default: false)
- Feature that forces all regular number values to be written as JSON Strings, instead of as JSON Numbers (that is, enclosed in double-quotes)
- Maps to
JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS