Go 1.27 moves encoding/json onto the v2 engine
In Go 1.27 the existing encoding/json package is now backed by the new encoding/json/v2 engine, so behavior changes even without switching imports. Nil slices become [], field names match case-sensitively, duplicate keys and invalid UTF-8 are rejected, and time.Duration no longer marshals by default.
- encoding/json in Go 1.27 runs on the v2 engine, v1 API kept
- Nil slices now encode as [] instead of null; duplicate keys rejected
- time.Duration needs FormatDurationAsNano(true) to marshal
- Opt-out via GOEXPERIMENT=nojsonv2 is expected to be removed later
Read next
Software