inf := math.Inf(1)
json.Marshal(inf)
json.Marshal(struct{ F float64 }{inf})
json.Marshal(map[string]any{"k": inf})
v1 returns "json: unsupported value: +Inf" in all three cases.
v2 (including v1 with GOEXPERIMENT=jsonv2) returns "json: unsupported value: +Inf" in the first two cases, but succeeds and returns {"k":"Infinity"}
in the third case.
Seems like an unintentional change? I'd expect all three cases to succeed or fail.
Comment From: neild
/cc @dsnet
Comment From: gabyhelp
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)