1
0
mirror of https://github.com/json-iterator/go.git synced 2025-12-23 23:33:38 +02:00

support Any as field type

This commit is contained in:
Tao Wen
2017-04-28 09:09:24 +08:00
parent e5476f70e7
commit 8711c74c85
3 changed files with 30 additions and 1 deletions

View File

@@ -361,6 +361,9 @@ func (p prefix) addToEncoder(encoder Encoder, err error) (Encoder, error) {
}
func decoderOfType(typ reflect.Type) (Decoder, error) {
if typ.ConvertibleTo(anyType) {
return &anyCodec{}, nil
}
typeName := typ.String()
typeDecoder := typeDecoders[typeName]
if typeDecoder != nil {