1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

test reading into custom interface

This commit is contained in:
Tao Wen
2017-01-25 23:25:25 +08:00
parent f1c4dbde29
commit ce1a1f1e98
2 changed files with 36 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"reflect"
"sync/atomic"
"unsafe"
"errors"
)
/*
@ -345,7 +346,11 @@ func decoderOfType(typ reflect.Type) (Decoder, error) {
case reflect.Bool:
return &boolCodec{}, nil
case reflect.Interface:
return &interfaceCodec{}, nil
if typ.NumMethod() == 0 {
return &interfaceCodec{}, nil
} else {
return nil, errors.New("unsupportd type: " + typ.String())
}
case reflect.Struct:
return prefix(fmt.Sprintf("[%s]", typeName)).addToDecoder(decoderOfStruct(typ))
case reflect.Slice: