Unable to set options (UseNumber
& DisallowUnknownFields()
) on the json decoder
#514
Labels
UseNumber
& DisallowUnknownFields()
) on the json decoder
#514
Is your feature request related to a problem? Please describe.
Here's documentation for the two options:
Currently, while it's possible to set a few fields on the encoder (
SetEscapeHTML(...)
&SetIndent(...)
), it's not possible to set any on the decoder.An example reason why someone would want to use number is that by default, the json decoding library uses a
float64
to represent a number value. If the number is intended to always be an integer, casting it first to float and then to integer is confusing and might introduce a chance of error in the code.Describe the solution you'd like
#513
Describe alternatives you've considered
Before this change, the lambda API supported setting some of the json encoder options (
SetEscapeHTML(...)
&SetIndent(...)
). I needed the ability to set the UseNumber() option on the decoder and I considered setting it in the same way (by creating a one-off option), but instead I ended up creating two new options that allow setting arbitrary fields on the encoder and decoder.I think this is a better option because it's future-proof (if new options are added to the json library, this library won't also need to be changed to make this option available) and more backward compatible.
Additional context
N/A
The text was updated successfully, but these errors were encountered: