diff --git a/serializer/serix/decode.go b/serializer/serix/decode.go index 04fd74e44..0341ba89d 100644 --- a/serializer/serix/decode.go +++ b/serializer/serix/decode.go @@ -175,8 +175,8 @@ func (api *API) decodeBasedOnType(ctx context.Context, b []byte, value reflect.V return deseri.Done() - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64: deseri := serializer.NewDeserializer(b) addrValue := value.Addr() diff --git a/serializer/serix/encode.go b/serializer/serix/encode.go index a597c1417..201a7c336 100644 --- a/serializer/serix/encode.go +++ b/serializer/serix/encode.go @@ -126,8 +126,8 @@ func (api *API) encodeBasedOnType( return ierrors.Wrap(err, "failed to write bool value to serializer") }).Serialize() - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64: _, typeToConvert, _ := getNumberTypeToConvert(valueType.Kind()) value = value.Convert(typeToConvert) diff --git a/serializer/serix/map_decode.go b/serializer/serix/map_decode.go index 4c213cf1f..b45043447 100644 --- a/serializer/serix/map_decode.go +++ b/serializer/serix/map_decode.go @@ -161,11 +161,11 @@ func (api *API) mapDecodeBasedOnType(ctx context.Context, mapVal any, value refl return nil case reflect.Int8, reflect.Int16, reflect.Int32: return api.mapDecodeNum(value, valueType, float64NumParser(mapVal.(float64), value.Kind(), true)) - case reflect.Int64: + case reflect.Int64, reflect.Int: return api.mapDecodeNum(value, valueType, strNumParser(mapVal.(string), 64, true)) case reflect.Uint8, reflect.Uint16, reflect.Uint32: return api.mapDecodeNum(value, valueType, float64NumParser(mapVal.(float64), value.Kind(), false)) - case reflect.Uint64: + case reflect.Uint64, reflect.Uint: return api.mapDecodeNum(value, valueType, strNumParser(mapVal.(string), 64, false)) case reflect.Float32, reflect.Float64: return api.mapDecodeFloat(value, valueType, mapVal) diff --git a/serializer/serix/map_encode.go b/serializer/serix/map_encode.go index b768987b7..08df238af 100644 --- a/serializer/serix/map_encode.go +++ b/serializer/serix/map_encode.go @@ -101,11 +101,11 @@ func (api *API) mapEncodeBasedOnType( return value.Bool(), nil case reflect.Int8, reflect.Int16, reflect.Int32: return value.Int(), nil - case reflect.Int64: + case reflect.Int64, reflect.Int: return strconv.FormatInt(value.Int(), 10), nil case reflect.Uint8, reflect.Uint16, reflect.Uint32: return value.Uint(), nil - case reflect.Uint64: + case reflect.Uint64, reflect.Uint: return strconv.FormatUint(value.Uint(), 10), nil case reflect.Float32, reflect.Float64: return strconv.FormatFloat(value.Float(), 'E', -1, 64), nil diff --git a/serializer/serix/map_encode_test.go b/serializer/serix/map_encode_test.go index bdc873703..9c4db61d5 100644 --- a/serializer/serix/map_encode_test.go +++ b/serializer/serix/map_encode_test.go @@ -76,10 +76,12 @@ func TestMapEncodeDecode(t *testing.T) { name: "basic types", paras: func() paras { type example struct { + Uint uint `serix:"0,mapKey=uint"` Uint64 uint64 `serix:"0,mapKey=uint64"` Uint32 uint32 `serix:"1,mapKey=uint32"` Uint16 uint16 `serix:"2,mapKey=uint16"` Uint8 uint8 `serix:"3,mapKey=uint8"` + Int int `serix:"4,mapKey=int"` Int64 int64 `serix:"4,mapKey=int64"` Int32 int32 `serix:"5,mapKey=int32"` Int16 int16 `serix:"6,mapKey=int16"` @@ -97,10 +99,12 @@ func TestMapEncodeDecode(t *testing.T) { return paras{ api: api, in: &example{ + Uint: 1, Uint64: 64, Uint32: 32, Uint16: 16, Uint8: 8, + Int: 1, Int64: -64, Int32: -32, Int16: -16, @@ -115,10 +119,12 @@ func TestMapEncodeDecode(t *testing.T) { }(), expected: `{ "type": 42, + "uint": "1", "uint64": "64", "uint32": 32, "uint16": 16, "uint8": 8, + "int": "1", "int64": "-64", "int32": -32, "int16": -16, diff --git a/serializer/serix/serix.go b/serializer/serix/serix.go index 00071535b..19d901ef3 100644 --- a/serializer/serix/serix.go +++ b/serializer/serix/serix.go @@ -988,7 +988,7 @@ func getNumberTypeToConvert(kind reflect.Kind) (int, reflect.Type, reflect.Type) case reflect.Int32: numberType = reflect.TypeOf(int32(0)) bitSize = 32 - case reflect.Int64: + case reflect.Int64, reflect.Int: numberType = reflect.TypeOf(int64(0)) bitSize = 64 case reflect.Uint8: @@ -1000,7 +1000,7 @@ func getNumberTypeToConvert(kind reflect.Kind) (int, reflect.Type, reflect.Type) case reflect.Uint32: numberType = reflect.TypeOf(uint32(0)) bitSize = 32 - case reflect.Uint64: + case reflect.Uint64, reflect.Uint: numberType = reflect.TypeOf(uint64(0)) bitSize = 64 case reflect.Float32: