MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / decode

Function decode

libs/json/decoder.go:17–37  ·  view source on GitHub ↗
(bz []byte, v interface{})

Source from the content-addressed store, hash-verified

15}
16
17func decode(bz []byte, v interface{}) error {
18 if len(bz) == 0 {
19 return errors.New("cannot decode empty bytes")
20 }
21
22 rv := reflect.ValueOf(v)
23 if rv.Kind() != reflect.Ptr {
24 return errors.New("must decode into a pointer")
25 }
26 rv = rv.Elem()
27
28 // If this is a registered type, defer to interface decoder regardless of whether the input is
29 // an interface or a bare value. This retains Amino's behavior, but is inconsistent with
30 // behavior in structs where an interface field will get the type wrapper while a bare value
31 // field will not.
32 if typeRegistry.name(rv.Type()) != "" {
33 return decodeReflectInterface(bz, rv)
34 }
35
36 return decodeReflect(bz, rv)
37}
38
39func decodeReflect(bz []byte, rv reflect.Value) error {
40 if !rv.CanAddr() {

Callers 1

UnmarshalFunction · 0.85

Calls 4

decodeReflectInterfaceFunction · 0.85
decodeReflectFunction · 0.85
nameMethod · 0.80
TypeMethod · 0.65

Tested by

no test coverage detected