mirror of
https://github.com/gogf/gf.git
synced 2025-04-05 11:18:50 +08:00
fix issue #1747
This commit is contained in:
parent
d0f2928cec
commit
d5e5a48170
@ -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
|
||||
|
@ -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`)
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user