You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"encoding/json"
"github.com/tidwall/gjson"
"testing"
)
func TestGjson(t *testing.T) {
data := `{"id":7328334202200869666}`
r := gjson.Parse(data)
t.Log("r", r)
t.Logf("r.Value() %s", r.Value())
bytes, err := json.Marshal(r.Value())
if err != nil {
panic(err)
}
t.Log("bytes", string(bytes))
}
Print is:
=== RUN TestGjson
json_test.go:13: r {"id":7328334202200869666}
json_test.go:14: r.Value() map[id:%!s(float64=7.32833420220087e+18)]
json_test.go:21: bytes {"id":7328334202200870000}
after processing by method Value() , the number be parse as a float64 and miss precision.
maybe gjson can provide a params or config like UseNumber in std encoding/json lib in this scenario
The text was updated successfully, but these errors were encountered:
Test code:
Print is:
after processing by method
Value()
, the number be parse as a float64 and miss precision.maybe gjson can provide a params or config like
UseNumber
in stdencoding/json
lib in this scenarioThe text was updated successfully, but these errors were encountered: