in proxy/protocol/dubbo/utils/typeutil.go [189:223]
func RestByteToValue(jType string, value []byte) (interface{}, error) {
switch jType {
case JavaString, SchemaString:
return string(value[:]), nil
case JavaChar:
case JavaByte:
return value, nil
case JavaShort:
return int16(binary.BigEndian.Uint16(value)), nil
case JavaInteger:
return int32(binary.BigEndian.Uint32(value)), nil
case JavaLong:
return int64(binary.BigEndian.Uint32(value)), nil
case JavaFloat:
bits := binary.LittleEndian.Uint32(value)
return math.Float32frombits(bits), nil
case JavaDouble:
bits := binary.LittleEndian.Uint64(value)
return math.Float64frombits(bits), nil
case JavaBoolean:
return nil, &BaseError{"Not supported"}
case JavaArray, SchemaArray:
return nil, &BaseError{"Not supported "}
case JavaObject, SchemaObject:
var tmp interface{}
err := json.Unmarshal(value, &tmp) //对象类型直接使用json格式
if err != nil {
return nil, err
}
return tmp, nil
default:
return nil, &BaseError{"Invalid type"}
}
return nil, nil
}