Key details

  1. Go team announcement published November 4, 2026; stable in Go 1.27.
  2. encoding/json/v2 and encoding/json/jsontext were experimental in Go 1.25.
  3. v2 rejects duplicate JSON object names and invalid UTF-8 by default.
  4. Struct matching is case-sensitive and nil maps/slices encode as empty collections.
  5. Streaming token APIs and caller-provided options are first-class.
  6. Original encoding/json remains supported indefinitely and interoperates through a shared implementation.
  7. Go team reports up to 10x unmarshalling improvement in some benchmarks; not independently reproduced.

What builders should take away

  1. Run API contract tests before switching JSON packages; duplicate names and case handling may change responses.
  2. Test nil collections, omitempty, time.Duration and custom marshalers.
  3. Use jsontext for streaming workloads where full-value buffering is costly.
  4. Migrate incrementally with compatibility options rather than wholesale replacements.
  5. Benchmark representative payloads rather than assuming advertised gains.

What changed

On November 4, 2026, the Go team announced that encoding/json/v2 and encoding/json/jsontext are stable and generally available in Go 1.27, after experimentation in Go 1.25. The v2 API rejects duplicate JSON object keys and invalid UTF-8 by default, matches struct fields case-sensitively, changes nil slice/map encoding and omitempty semantics, and exposes streaming marshal/unmarshal operations. The existing encoding/json v1 remains supported indefinitely and is implemented using the v2 engine with compatibility options.

Why it matters

JSON is a core boundary for Go web services and integrations. Ambiguous duplicate keys, lenient Unicode handling and surprising case-insensitive field matching can produce security or interoperability problems. The stable v2 API provides safer defaults and true streaming without forcing existing code to migrate immediately. Developers must test behavioural differences before switching, especially around empty values, time.Duration, struct matching and custom marshalers.

Strict parsing changes what inputs are accepted

Version 2 rejects invalid UTF-8 and duplicate object members and uses case-sensitive field matching by default. These differences improve predictable cross-system interpretation but can break callers that relied on permissive v1 behaviour.

Streaming and extensibility become first-class

The jsontext Encoder/Decoder work with tokens and values; v2 adds MarshalWrite, UnmarshalRead, MarshalEncode and UnmarshalDecode plus caller-configurable options and new streaming custom marshaler interfaces. That can avoid buffering and repeated parsing for some workloads.

Compatibility is a gradual migration, not a flag day

The old encoding/json API remains supported. Under the hood, v1 is implemented on the v2 engine with v1 compatibility options, allowing v1 and v2 custom methods to interoperate. Teams can adopt v2 callsite by callsite and explicitly opt into old behaviours where required.

Performance claims need workload testing

The Go team reports unmarshalling improvements reaching 10x in some benchmarks, with marshal performance roughly comparable. Those results are upstream measurements, not a guarantee for an individual application. Benchmarks and regression tests should cover actual schemas, allocations and streaming behaviour.

What to watch next

  • Go 1.28 JSON performance improvements.
  • Library adoption and compatibility findings.
  • Security or interoperability reports from stricter defaults.

Still unclear

  • Benchmarks are upstream-produced and depend on workload.
  • Some third-party libraries may assume v1 semantics.
  • Adoption and ecosystem migration rates remain unmeasured.

Sources

Direct reading behind this dossier.

2 sources
A new Go API for JSON
Go team primary

Official stability announcement, API and behaviour differences, compatibility and project benchmarks.

Discussion

Discussion is reader-contributed. Comments are not part of the BTN dossier or its editorial evidence.

0 visible comments

Join the discussion

Keep comments useful and relevant. Reader contributions may be moderated and are not BTN editorial evidence.

Sign in to comment