diff --git a/pkg/flexint/flexint.go b/pkg/flexint/flexint.go index 524ceac..63e1fbb 100644 --- a/pkg/flexint/flexint.go +++ b/pkg/flexint/flexint.go @@ -3,6 +3,7 @@ package flexint import ( "encoding/json" "errors" + "fmt" "math" "strconv" ) @@ -25,6 +26,7 @@ func (i *Int64) UnmarshalJSON(data []byte) error { // Try to unmarshal as a float64 and then convert var floatVal float64 if err := json.Unmarshal(data, &floatVal); err == nil { + fmt.Printf("floatVal: %f\n", floatVal) // Debug print if floatVal > float64(math.MaxInt64) { *i = Int64(math.MaxInt64) } else if floatVal < float64(math.MinInt64) { diff --git a/pkg/flexint/flexint_test.go b/pkg/flexint/flexint_test.go index c8f935f..9b2ce1b 100644 --- a/pkg/flexint/flexint_test.go +++ b/pkg/flexint/flexint_test.go @@ -21,6 +21,7 @@ func TestUnmarshalJSON(t *testing.T) { {"floating point value round half to even 12344.5", "12344.5", 12344, false}, {"max int64", "9223372036854775807", Int64(math.MaxInt64), false}, {"min int64", "-9223372036854775808", Int64(math.MinInt64), false}, + {"float64 exceeds max int64", "9223372036854775808.0", Int64(math.MaxInt64), false}, {"float64 below min int64", "-9223372036854775809.0", Int64(math.MinInt64), false}, {"string integer value", `"12345"`, 12345, false}, {"string floating point value", `"12345.67"`, 12346, false},