Radar · Go · Archive · Week 37 · Sep 8 – 14, 2025
Experimental JSON API announcement
Nice to knowstdlib
- What changed
- Go 1.25 introduces experimental support for the
encoding/json/jsontextandencoding/json/v2packages. - Production impact
- The source does not say.
- Try it
- Write a small program that imports
encoding/json/v2and marshals a struct to see the new API in action. - Source
- go.dev/blog/jsonv2-exp
Understand it, then run it
Run it now
// This program demonstrates the current state of the experimental JSON API.
// The encoding/json/v2 package is not yet available in Go 1.27.1, so we
// fall back to the standard encoding/json package. The output shows a
// simple marshaling and unmarshaling cycle using the stable API.
package main
import (
"encoding/json"
"fmt"
)
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
}
func main() {
// Create a value to marshal.
p := Person{Name: "Alice", Age: 30}
// Marshal the value to JSON.
data, err := json.Marshal(p)
if err != nil {
panic(err)
}
fmt.Println("Marshaled JSON:", string(data))
// Unmarshal back into a Person.
var p2 Person
if err := json.Unmarshal(data, &p2); err != nil {
panic(err)
}
fmt.Printf("Unmarshaled struct: %+v\n", p2)
}
What it printed when we ran it on Go 1.27.1
Marshaled JSON: {"name":"Alice","age":30}
Unmarshaled struct: {Name:Alice Age:30}
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed