← All recipes
Moderne licensed

Preserve v1 semantics on encoding/json/v2 calls

Recipe IDorg.openrewrite.golang.migration.PreserveV1SemanticsArtifactgithub.com/moderneinc/recipes-go

Append jsonv1.DefaultOptionsV1() to encoding/json/v2 marshal and unmarshal calls, adding the jsonv1 "encoding/json" import, to re-enable the v1 defaults that v2 changed. DefaultOptionsV1 is the v1 compatibility bundle from the encoding/json package.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.golang.migration.PreserveV1Semantics

If the recipe isn’t available locally, install it with:

mod config recipes go install github.com/moderneinc/recipes-go