We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4de15a3 commit 73c7bc8Copy full SHA for 73c7bc8
feature_json_number.go
@@ -1,9 +1,25 @@
1
package jsoniter
2
3
-import "encoding/json"
+import (
4
+ "encoding/json"
5
+ "strconv"
6
+)
7
8
type Number string
9
10
+// String returns the literal text of the number.
11
+func (n Number) String() string { return string(n) }
12
+
13
+// Float64 returns the number as a float64.
14
+func (n Number) Float64() (float64, error) {
15
+ return strconv.ParseFloat(string(n), 64)
16
+}
17
18
+// Int64 returns the number as an int64.
19
+func (n Number) Int64() (int64, error) {
20
+ return strconv.ParseInt(string(n), 10, 64)
21
22
23
func CastJsonNumber(val interface{}) (string, bool) {
24
switch typedVal := val.(type) {
25
case json.Number:
0 commit comments