You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I am implementing CBOR support as a binary alternative to an existing (encoding/json-based) JSON serialization layer. It's essential that all objects entering the system can continue to be JSON-encoded for consumption by existing clients. The JSON serializer refuses to encode or decode floating-point NaN or +/- Inf values, so I want to be able to configure the CBOR serializer to reject them as well.
CBOR-based protocols MAY specify that they treat arbitrary valid data as unexpected.
I would like to be able to configure both EncMode and DecMode to return errors rather than encode or decode NaN and Inf floating-point values. Specifically:
Extend the existing NaNConvertMode and InfConvertMode with new modes NaNConvertReject and InfConvertReject, respectively, because configuring an accepted conversion is mutually exclusive with rejection. If so configured, marshaling will return UnsupportedValueError when asked to encode a NaN or infinity value. The default mode for both options will remain unchanged.
Add new decode options NaNDec and InfDec with "Allow" (default) and "Reject" modes. In the reject modes, unmarshaling will return UnacceptableDataItemError if a NaN or infinity floating-point value is encountered in the input.
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I am implementing CBOR support as a binary alternative to an existing (
encoding/json
-based) JSON serialization layer. It's essential that all objects entering the system can continue to be JSON-encoded for consumption by existing clients. The JSON serializer refuses to encode or decode floating-point NaN or +/- Inf values, so I want to be able to configure the CBOR serializer to reject them as well.Describe the solution you'd like
Based on https://www.rfc-editor.org/rfc/rfc8949.html#section-5-3:
I would like to be able to configure both EncMode and DecMode to return errors rather than encode or decode NaN and Inf floating-point values. Specifically:
NaNConvertMode
andInfConvertMode
with new modesNaNConvertReject
andInfConvertReject
, respectively, because configuring an accepted conversion is mutually exclusive with rejection. If so configured, marshaling will returnUnsupportedValueError
when asked to encode a NaN or infinity value. The default mode for both options will remain unchanged.NaNDec
andInfDec
with "Allow" (default) and "Reject" modes. In the reject modes, unmarshaling will returnUnacceptableDataItemError
if a NaN or infinity floating-point value is encountered in the input.Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: