From 04daa09e1911d7bdabe87e452200b2de2c5ca7c9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 10 Feb 2023 15:27:46 -0700 Subject: Be more careful about importing encoding/json --- encode.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'encode.go') diff --git a/encode.go b/encode.go index 492b40f..b6541cd 100644 --- a/encode.go +++ b/encode.go @@ -8,7 +8,6 @@ import ( "bytes" "encoding" "encoding/base64" - "encoding/json" "fmt" "io" "reflect" @@ -96,12 +95,6 @@ func discardInt(_ int, err error) error { return err } -var ( - encodableType = reflect.TypeOf((*Encodable)(nil)).Elem() - jsonMarshalerType = reflect.TypeOf((*json.Marshaler)(nil)).Elem() - textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() -) - const startDetectingCyclesAfter = 1000 func encode(w *ReEncoder, val reflect.Value, escaper BackslashEscaper, quote bool, cycleDepth uint, cycleSeen map[any]struct{}) error { @@ -145,7 +138,7 @@ func encode(w *ReEncoder, val reflect.Value, escaper BackslashEscaper, quote boo if val.Kind() == reflect.Pointer && val.IsNil() { return discardInt(w.WriteString("null")) } - obj, ok := val.Interface().(json.Marshaler) + obj, ok := val.Interface().(jsonMarshaler) if !ok { return discardInt(w.WriteString("null")) } -- cgit v1.2.3-2-g168b