diff --git a/encoding/gjson/gjson_implements.go b/encoding/gjson/gjson_implements.go index 60e146885..36dd0545f 100644 --- a/encoding/gjson/gjson_implements.go +++ b/encoding/gjson/gjson_implements.go @@ -13,7 +13,10 @@ func (j Json) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (j *Json) UnmarshalJSON(b []byte) error { - r, err := LoadContent(b) + r, err := loadContentWithOptions(b, Options{ + Type: ContentTypeJson, + StrNumber: true, + }) if r != nil { // Value copy. *j = *r diff --git a/encoding/gjson/gjson_z_unit_test.go b/encoding/gjson/gjson_z_unit_test.go index 6691024c6..7f7726301 100644 --- a/encoding/gjson/gjson_z_unit_test.go +++ b/encoding/gjson/gjson_z_unit_test.go @@ -15,6 +15,7 @@ import ( "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_New(t *testing.T) { @@ -576,3 +577,13 @@ func Test_Issue1617(t *testing.T) { }) }) } + +// https://github.com/gogf/gf/issues/1747 +func Test_Issue1747(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var j *gjson.Json + err := gconv.Struct(gvar.New("[1, 2, 336371793314971759]"), &j) + t.AssertNil(err) + t.Assert(j.Get("2"), `336371793314971759`) + }) +}