Kubernetes requires round-trips to work for all 64-bit (signed) integers; and has hence built machinery here and here to fix this by first trying to decode the JSON number (at that point represented as a string) first using strconv.ParseInt() and then, only if that fails, strconv.ParseFloat.
The JSON package of deklarative shall have this feature built-into the decoder, and use it as the default mode.
By default,
encoding/json
decodes all JSON numbers intofloat64
. Due to the nature of how float64's work, it can store integers "only" in the range[-2^53, 2^53]
(see https://en.wikipedia.org/wiki/Double-precision_floating-point_format#Precision_limitations_on_integer_values and https://datatracker.ietf.org/doc/html/rfc8259#section-6).Illustration: https://play.golang.org/p/mpZK8T1NChA
Kubernetes requires round-trips to work for all 64-bit (signed) integers; and has hence built machinery here and here to fix this by first trying to decode the JSON number (at that point represented as a string) first using
strconv.ParseInt()
and then, only if that fails,strconv.ParseFloat
.The JSON package of deklarative shall have this feature built-into the decoder, and use it as the default mode.