diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-10 15:27:46 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-10 21:48:22 -0700 |
commit | 04daa09e1911d7bdabe87e452200b2de2c5ca7c9 (patch) | |
tree | 4e125b226bec6c9ec33335c4d9ff3bdfd874242c /encode.go | |
parent | 1f0abce0bf4061261572f6ed2f815f71647cc7e5 (diff) |
Be more careful about importing encoding/json
Diffstat (limited to 'encode.go')
-rw-r--r-- | encode.go | 9 |
1 files changed, 1 insertions, 8 deletions
@@ -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")) } |