By default, when serializing double
and float
properties, the System.Text.Json
serializer uses the "G17" format when serializing double types. This format omits
the decimal point and/or trailing zeros if they are not required for the data to
roundtrip. This is generally correct, as JSON doesn’t specify a type for numbers.
However, in the case of source serialization, mappings for numeric properties may
be incorrectly inferred if trailing zeros are omitted. In this release, we have
included a new custom converter for float
and double
types when serialized using
the default source serializer. These converters ensure that at least one precision
digit is included after a decimal point, even for round numbers.
You may therefore observe changes to the serialized source document after upgrading to this version.