-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels