Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface SerializationFeature

Interface that defines features to set for ObjectMapper and JsonStringifier.

Changes only take effect when done before any serialization calls -- that is, caller must follow "configure-then-use" pattern.

Hierarchy

Index

Properties

Optional DEFAULT_PROPERTY_INCLUSION

DEFAULT_PROPERTY_INCLUSION: JsonIncludeBaseOptions | null

Feature that define global inclusion rules about which properties of a Class are to be included in serialization.

null indicates that no global inclusion rules are defined.

Optional DEFAULT_VIEW_INCLUSION

DEFAULT_VIEW_INCLUSION: boolean

Feature that determines whether properties that have no view decorators are included in JSON serialization views (see JsonView for more details on JSON Views).

If enabled, non-decorated properties will be included; when disabled, they will be excluded. So this feature changes between "opt-in" (feature disabled) and "opt-out" (feature enabled) modes.

Default value is enabled, meaning that non-decorated properties are included in all views if there is no JsonView decorator.

Optional FAIL_ON_SELF_REFERENCES

FAIL_ON_SELF_REFERENCES: boolean

Feature that determines what happens when a direct self-reference is detected by a Class (and no Object Id handling is enabled for it): either a JacksonError is thrown (if true), or reference is normally processed (false).

Optional ORDER_MAP_AND_OBJECT_LITERAL_ENTRIES_BY_KEYS

ORDER_MAP_AND_OBJECT_LITERAL_ENTRIES_BY_KEYS: boolean

Feature that determines whether Map or Object Literal entries are first sorted by key before serialization or not: if enabled, additional sorting step is performed, if disabled, no additional sorting is needed.

Optional SET_DEFAULT_VALUE_FOR_BIGINT_ON_NULL

SET_DEFAULT_VALUE_FOR_BIGINT_ON_NULL: boolean

Feature that determines whether BigInt primitive type properties that contains null value should be serialized/deserialized with its default value or not. If enabled, during serialization, the property will be serialized with its default value. Instead, during deserialization, the null value will be substituted with its default value.

The default BigInt value is 0n.

Optional SET_DEFAULT_VALUE_FOR_BOOLEAN_ON_NULL

SET_DEFAULT_VALUE_FOR_BOOLEAN_ON_NULL: boolean

Feature that determines whether Boolean primitive type properties that contains null value should be serialized/deserialized with its default value or not. If enabled, during serialization, the property will be serialized with its default value. Instead, during deserialization, the null value will be substituted with its default value.

The default Boolean value is false.

Optional SET_DEFAULT_VALUE_FOR_NUMBER_ON_NULL

SET_DEFAULT_VALUE_FOR_NUMBER_ON_NULL: boolean

Feature that determines whether Number primitive type properties that contains null value should be serialized/deserialized with its default value or not. If enabled, during serialization, the property will be serialized with its default value. Instead, during deserialization, the null value will be substituted with its default value.

The default Number value is 0.

Optional SET_DEFAULT_VALUE_FOR_PRIMITIVES_ON_NULL

SET_DEFAULT_VALUE_FOR_PRIMITIVES_ON_NULL: boolean

Feature that determines whether primitive type properties that contains null value should be serialized/deserialized with its default value or not. If enabled, during serialization, the property will be serialized with its default value. Instead, during deserialization, the null value will be substituted with its default value.

Default values are:

  • Number: 0;
  • String: "";
  • Boolean: false;
  • BigInt: 0n;
  • null for all other JavaScript types.

Optional SET_DEFAULT_VALUE_FOR_STRING_ON_NULL

SET_DEFAULT_VALUE_FOR_STRING_ON_NULL: boolean

Feature that determines whether String primitive type properties that contains null value should be serialized/deserialized with its default value or not. If enabled, during serialization, the property will be serialized with its default value. Instead, during deserialization, the null value will be substituted with its default value.

The default String value is "".

Optional SORT_PROPERTIES_ALPHABETICALLY

SORT_PROPERTIES_ALPHABETICALLY: boolean

Feature that defines default property serialization order used for Class fields (note: does not apply to Map or Object Literals serialization!): if enabled, default ordering is alphabetic (similar to how JsonPropertyOrder with JsonPropertyOrderOptions.alphabetic works); if disabled, order is unspecified (based on what JavaScript gives us, which may be declaration order, but is not guaranteed).

Optional WRAP_ROOT_VALUE

WRAP_ROOT_VALUE: boolean

Feature that can be enabled to make root value wrapped within a single property JSON object, where key as the "root name".

Optional WRITE_DATES_AS_TIMESTAMPS

WRITE_DATES_AS_TIMESTAMPS: boolean

Feature that determines whether Date values are to be serialized as numeric time stamps or not.

Optional WRITE_DATE_KEYS_AS_TIMESTAMPS

WRITE_DATE_KEYS_AS_TIMESTAMPS: boolean

Feature that determines whether Dates used as Map or Object Literal keys are serialized as time stamps or not (if not, will be serialized as textual values).

Optional WRITE_NAN_AS_ZERO

WRITE_NAN_AS_ZERO: boolean

Feature that determines whether NaN values should be serialized as 0 or not.

Optional WRITE_NEGATIVE_INFINITY_AS_NUMBER_MIN_SAFE_INTEGER

WRITE_NEGATIVE_INFINITY_AS_NUMBER_MIN_SAFE_INTEGER: boolean

Feature that determines whether negative Infinity values should be serialized as Number.MIN_SAFE_INTEGER or not.

Optional WRITE_NEGATIVE_INFINITY_AS_NUMBER_MIN_VALUE

WRITE_NEGATIVE_INFINITY_AS_NUMBER_MIN_VALUE: boolean

Feature that determines whether negative Infinity values should be serialized as Number.MIN_VALUE or not.

Optional WRITE_POSITIVE_INFINITY_AS_NUMBER_MAX_SAFE_INTEGER

WRITE_POSITIVE_INFINITY_AS_NUMBER_MAX_SAFE_INTEGER: boolean

Feature that determines whether positive Infinity values should be serialized as Number.MAX_SAFE_INTEGER or not.

Optional WRITE_POSITIVE_INFINITY_AS_NUMBER_MAX_VALUE

WRITE_POSITIVE_INFINITY_AS_NUMBER_MAX_VALUE: boolean

Feature that determines whether positive Infinity values should be serialized as Number.MAX_VALUE or not.

Optional WRITE_SELF_REFERENCES_AS_NULL

WRITE_SELF_REFERENCES_AS_NULL: boolean

Feature that determines what happens when a direct self-reference is detected by a Class (and no Object Id handling is enabled for it): if enabled write that reference as null; if disabled, default behavior is used (which will try to serialize usually resulting in exception). But if FAIL_ON_SELF_REFERENCES is enabled, this property is ignored.

Generated using TypeDoc