avro
avro copied to clipboard
AVRO-2032: [C#] Add support for NaN, Infinity and -Infinity in JsonDecoder
What is the purpose of the change
JsonEncoder uses special string values to represent NaN, Infinity and -Infinity values for float and double values, but JsonDecoder does not accept these string values. This change adds support for these special values to JsonDecoder.
Verifying this change
This change added tests and can be verified as follows:
- The change adds an unit tests which verifies all 6 special cases:
-
NaNfor float fields -
NaNfor double fields -
Infinityfor float fields -
Infinityfor double fields -
-Infinityfor float fields -
-Infinityfor double fields
-
- These values are defined in Jackson.
StdDeserializer
Documentation
- This PR doesn't introduce a new feature but implements a behavior which is not documented at all.
- The Avro spec doesn't mention how these special cases are handled in JSON (RFC 8259 does not define numeric literals for
NaN,Infinityand-Infinity) -
JsonEncoder/JsonDecoderresemble the behavior of Jackson
Same as #3066