Explorar el Código

Merge branch 'master' of https://github.com/json-iterator/go

Tao Wen hace 8 años
padre
commit
e7a8aea845
Se han modificado 2 ficheros con 13 adiciones y 0 borrados
  1. 6 0
      feature_iter_float.go
  2. 7 0
      jsoniter_float_test.go

+ 6 - 0
feature_iter_float.go

@@ -1,6 +1,7 @@
 package jsoniter
 
 import (
+	"encoding/json"
 	"io"
 	"math/big"
 	"strconv"
@@ -339,3 +340,8 @@ func validateFloat(str string) string {
 	}
 	return ""
 }
+
+// ReadNumber read json.Number
+func (iter *Iterator) ReadNumber() (ret json.Number) {
+	return json.Number(iter.readNumberAsString())
+}

+ 7 - 0
jsoniter_float_test.go

@@ -192,6 +192,13 @@ func Test_lossy_float_marshal(t *testing.T) {
 	should.Equal("0.123457", output)
 }
 
+func Test_read_number(t *testing.T) {
+	should := require.New(t)
+	iter := ParseString(ConfigDefault, `92233720368547758079223372036854775807`)
+	val := iter.ReadNumber()
+	should.Equal(`92233720368547758079223372036854775807`, string(val))
+}
+
 func Benchmark_jsoniter_float(b *testing.B) {
 	b.ReportAllocs()
 	input := []byte(`1.1123,`)