From 2049abfd2f74041f1efab67eb967099640baf1f6 Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 4 Dec 2017 17:59:56 +0900 Subject: [PATCH] ing --- encoding/json/json.go | 1 + encoding/json/number.go | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 encoding/json/json.go create mode 100644 encoding/json/number.go 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 +}