util/encoding/json/number.go

12 lines
168 B
Go
Raw Normal View History

2017-12-04 08:59:56 +00:00
package json
import "encoding/json"
func NumberToInt(n json.Number) (int, error) {
n64, err := n.Int64()
if nil != err {
return 0, err
}
return int(n64), nil
}