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 }