diff --git a/encoding/json/json.go b/encoding/json/json.go new file mode 100644 index 0000000..a5b981c --- /dev/null +++ b/encoding/json/json.go @@ -0,0 +1 @@ +package json diff --git a/encoding/json/number.go b/encoding/json/number.go new file mode 100644 index 0000000..5cddf22 --- /dev/null +++ b/encoding/json/number.go @@ -0,0 +1,11 @@ +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 +}