MCPcopy Create free account
hub / github.com/segmentio/encoding / decodeMaybeEmptyInterface

Method decodeMaybeEmptyInterface

json/decode.go:1398–1413  ·  view source on GitHub ↗
(b []byte, p unsafe.Pointer, t reflect.Type)

Source from the content-addressed store, hash-verified

1396}
1397
1398func (d decoder) decodeMaybeEmptyInterface(b []byte, p unsafe.Pointer, t reflect.Type) ([]byte, error) {
1399 if hasNullPrefix(b) {
1400 *(*any)(p) = nil
1401 return b[4:], nil
1402 }
1403
1404 if x := reflect.NewAt(t, p).Elem(); !x.IsNil() {
1405 if e := x.Elem(); e.Kind() == reflect.Ptr {
1406 return Parse(b, e.Interface(), d.flags)
1407 }
1408 } else if t.NumMethod() == 0 { // empty interface
1409 return Parse(b, (*any)(p), d.flags)
1410 }
1411
1412 return d.decodeUnmarshalTypeError(b, p, t)
1413}
1414
1415func (d decoder) decodeUnmarshalTypeError(b []byte, _ unsafe.Pointer, t reflect.Type) ([]byte, error) {
1416 v, b, _, err := d.parseValue(b)

Calls 5

hasNullPrefixFunction · 0.85
ParseFunction · 0.70
ElemMethod · 0.65
KindMethod · 0.65

Tested by

no test coverage detected