Go 1.27: encoding/json/v2, Stricter Defaults, and Finally [] for Nil Slices
The Go team just shipped encoding/json/v2 as stable in Go 1.27. It’s been available behind GOEXPERIMENT=jsonv2 since 1.25, and I’ve been meaning to try it ever since (I never got around to it). So now I finally did.
First of all: I have some mixed feelings about encoding/json. It works fine most of the time, but it also accepts quite a lot of stuff it shouldn’t, without telling you. Coming from Elm, where a decoder fails the moment something doesn’t match, v1 always felt a bit too forgiving for my taste. v2 is a lot stricter, and I like it!
参与讨论