Skip to content
IJK

Why Go Added a New JSON Major Version: The Problems It Names

By IJK ·

The problems the Go team's post names in the existing JSON package, why it says they cannot be fixed in place and what the new decoders do differently.

The problems the post names

This is a surprising default, a potential security vulnerability, and a performance limitation. [1]

Unfortunately, these problems are inherent consequences of the existing API, making them practically impossible to fix within the Go 1 compatibility promise. [2]

soProblems inherent in the existing APIWithin the Go 1 compatibility promisepractically impossible to fixNew major versionstable in Go 1.27
What chain of reasoning does the post give for a new major version?

Why a new major version

Introducing a new, incompatible major version of a package is a heavy consideration. [3]

If possible, we should try to fix the existing package. [4]

While it is relatively easy to add new features, it is difficult to change existing features. [5]

What the new decoders do differently

Generally, decoders have become stricter at rejecting ambiguous inputs, to reduce the chance that two implementations will have different (successful) interpretations of a particular JSON value. [6]

After additional feedback and refinement, the new encoding/json/v2 and encoding/json/jsontext packages are stable and generally available in Go 1.27! [7]

Sources

  1. The Go Team source says: This is a surprising default, a potential security vulnerability, and a performance limitation. A new Go API for JSON
  2. The Go Team source says: Unfortunately, these problems are inherent consequences of the existing API, making them practically impossible to fix within the Go 1 compatibility promise. A new Go API for JSON
  3. The Go Team source says: Introducing a new, incompatible major version of a package is a heavy consideration. A new Go API for JSON
  4. The Go Team source says: If possible, we should try to fix the existing package. A new Go API for JSON
  5. The Go Team source says: While it is relatively easy to add new features, it is difficult to change existing features. A new Go API for JSON
  6. The Go Team source says: Generally, decoders have become stricter at rejecting ambiguous inputs, to reduce the chance that two implementations will have different (successful) interpretations of a particular JSON value. A new Go API for JSON
  7. The Go Team source says: After additional feedback and refinement, the new encoding/json/v2 and encoding/json/jsontext packages are stable and generally available in Go 1.27! A new Go API for JSON

Editorial (AI-assisted; automatically checked, not human-reviewed). Each statement is linked to its source; check the source before relying on a detail.

  • go
  • json
  • security
  • api design