fix: gjson encode to string expect inconformity(issue 2520) (#2928)

This commit is contained in:
the harder the luckier
2023-09-04 21:19:22 +08:00
committed by GitHub
parent 000c7a92ed
commit eb11061bd2
2 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/util/gconv"
)
@ -587,3 +588,15 @@ func Test_Issue1747(t *testing.T) {
t.Assert(j.Get("2"), `336371793314971759`)
})
}
// https://github.com/gogf/gf/issues/2520
func Test_Issue2520(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
type test struct {
Unique *gvar.Var `json:"unique"`
}
t2 := test{Unique: gvar.New(gtime.Date())}
t.Assert(gjson.MustEncodeString(t2), gjson.New(t2).MustToJsonString())
})
}