Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It would be beneficial to be able to specify whether fields with a default value and set to null should be converted to null or the default value.

Public Interfaces

Add a configuration two configurations to JsonConverter:

Name: serialize.use.optional.null
Description: Whether to serialize fields that have a default value and that are null to the default value or to null. When set to .defaultfalse, the default value is used, otherwise null is used.
Type: Boolean
Default: false

Name: deserialize.use.optional.null
Description: Whether to serialize deserialize fields that have a default value and that are null to the default value or to null. When set to truefalse, the default value is used, otherwise null is used.
Type: Boolean
Default: truefalse

Proposed Changes

Update JsonConverter and JsonConverterConfig to handle the new configurationconfigurations.

Compatibility, Deprecation, and Migration Plan

The new configuration keeps configurations keep the current behavior by default so it will not affect existing users. Users can optionally opt-in the new behavior by setting the configuration to falsetrue.

Rejected Alternatives

  1. Always take null on an optional null field which has default value. It will break the compatibility and only cover partial cases.
  2. Add the configuration to ConverterConfig