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 two configurations a configuration to JsonConverter:

Name: serializereplace.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 false, the default value is used, otherwise null is used.
Type: Boolean
Default: false
Name: deserialize.use.optional.null.with.default
Description: Whether to deserialize replace fields that have a default value and that are null to the default value or to null. When set to falsetrue, the default value is used, otherwise null is used.
Type: Boolean
Default: falsetrue

Proposed Changes

Update JsonConverter and JsonConverterConfig to handle the new configurationsconfiguration.

Compatibility, Deprecation, and Migration Plan

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

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