stretchr / objx

Go package for dealing with maps, slices, JSON and other data.
MIT License
695 stars 75 forks source link

Get an Int value from JSON doesn't work #22

Closed webliupeng closed 6 years ago

webliupeng commented 7 years ago
o, err := objx.FromJSON(`{"foo": 1}`)
 if (err != nil) {
  panic(err)
}
println("foo", o.Get("foo").Int64())

It's return 0.

DineshGuptaa commented 6 years ago

It is give us value but in form Float64 instead of Int64 println("foo", o.Get("foo").Float64()). It will return value foo +1.000000e+000 I am unable to find why lib behave like this?

hanzei commented 6 years ago

59 fixed this problem.

o, err := objx.FromJSON(`{"foo": 1}`)
 if (err != nil) {
  panic(err)
}
println("foo", o.Get("foo").Int())

will return 1