Skip to content

Commit baf00b8

Browse files
committed
Remove relying on "encoding/json"
This originally depended on "encoding/json" if no options are passed and only depended on "github.com/go-json-experiment/v1" if options are passed. This was a faulty attempt at making it possible to detect divergences in behavior between the two, but it does not work. We may need to add explicit API to detect regressions between "encoding/json" and "github.com/go-json-experiment/json/v1". However, this is complicated by the fact that they will actually be the same package once Go 1.25 is released and the binary is built with GOEXPERIMENT=jsonv2.
1 parent 0018953 commit baf00b8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

jsonsplit.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ import (
133133
"time"
134134
"unicode"
135135

136-
jsonv1std "encoding/json"
137-
138136
jsonv2 "github.com/go-json-experiment/json" // TODO: Use "encoding/json/v2"
139137
jsontext "github.com/go-json-experiment/json/jsontext" // TODO: Use "encoding/json/jsontext"
140138
jsonv1 "github.com/go-json-experiment/json/v1" // TODO: Use "encoding/json"
@@ -443,7 +441,7 @@ const (
443441
// CallV2ButUponErrorReturnV1 specifies to call v2 by default,
444442
// but only when an error occurs, to call v1 and return its result instead.
445443
CallV2ButUponErrorReturnV1
446-
// OnlyCallV1 specifies to only call v2 functionality.
444+
// OnlyCallV2 specifies to only call v2 functionality.
447445
OnlyCallV2
448446

449447
maxCallMode
@@ -866,7 +864,7 @@ func isPointerToZero(p reflect.Value) bool {
866864
// but allows specifying options to override default v1 behavior.
867865
func jsonv1Marshal(v any, o ...jsonv2.Options) ([]byte, error) {
868866
if len(o) == 0 {
869-
return jsonv1std.Marshal(v)
867+
return jsonv1.Marshal(v)
870868
}
871869
var arr [8]jsonv2.Options
872870
return jsonv2.Marshal(v, append(append(arr[:0], jsonv1.DefaultOptionsV1()), o...)...)
@@ -876,7 +874,7 @@ func jsonv1Marshal(v any, o ...jsonv2.Options) ([]byte, error) {
876874
// but allows specifying options to override default v1 behavior.
877875
func jsonv1Unmarshal(b []byte, v any, o ...jsonv2.Options) error {
878876
if len(o) == 0 {
879-
return jsonv1std.Unmarshal(b, v)
877+
return jsonv1.Unmarshal(b, v)
880878
}
881879
var arr [8]jsonv2.Options
882880
return jsonv2.Unmarshal(b, v, append(append(arr[:0], jsonv1.DefaultOptionsV1()), o...)...)

0 commit comments

Comments
 (0)