Closed naueramant closed 2 years ago
Since i upgraded the package to 0.3.0 from 0.1.1 i have noticed that the behavior of the float conversion have changed. An example:
package main import ( "fmt" "github.com/stretchr/objx" ) func main() { m1 := objx.MustFromJSON(`{"foo": 1500.0}`) foo1 := m1.Get("foo").Float64(-1) fmt.Println(foo1) m2 := objx.MustFromJSON(`{"foo": 1500.1}`) foo2 := m2.Get("foo").Float64(-1) fmt.Println(foo2) }
Output:
-1 1500.1
Go playground: https://play.golang.org/p/BU-r9HkEZHE
Expected behavior should be that also 1500.0 even 1500 should be seen as a float and therefor not return the default value. One would expect that only non numerical values would return -1 in this example.
1500.0
1500
-1
I am having the same issue with Float32
Since i upgraded the package to 0.3.0 from 0.1.1 i have noticed that the behavior of the float conversion have changed. An example:
Output:
Go playground: https://play.golang.org/p/BU-r9HkEZHE
Expected behavior should be that also
1500.0
even1500
should be seen as a float and therefor not return the default value. One would expect that only non numerical values would return-1
in this example.