util/encoding/json/number.go
crusader 6cdd0515a5 ing
2017-12-04 18:31:23 +09:00

15 lines
211 B
Go

package json
import (
"encoding/json"
"strconv"
)
func NumberToInt(n json.Number) (int, error) {
n64, err := strconv.ParseInt(n.String(), 10, 32)
if nil != err {
return 0, err
}
return int(n64), nil
}