jsoniter-scala
jsoniter-scala copied to clipboard
Call default value method only if null value was parsed for the field
Currently it is called for all fields in the start of decoding method, for example:
private def d0(in: JsonReader, default: JsonCodecMakerSpec.this.Defaults): JsonCodecMakerSpec.this.Defaults = if (in.isNextToken('{')) {
var _s: String = Defaults.`<init>$default$1`;
...
_s = in.readString(_s)
Should be:
private def d0(in: JsonReader, default: JsonCodecMakerSpec.this.Defaults): JsonCodecMakerSpec.this.Defaults = if (in.isNextToken('{')) {
var _s: String = null;
...
_s = in.readString(_s)
if (_s == null) _s = Defaults.`<init>$default$1`;
Or use presence bits in p0, p1, ... , pN variables instead checking for null.
Related to refactoring required for adding support of default values for non-first list of arguments of primary constructors: https://github.com/plokhotnyuk/jsoniter-scala/issues/904