We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go
go version go1.19.12 windows/amd64
GoFrame
v2.5.4
Yes
package main import ( "encoding/json" "testing" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" ) type tFF struct { Val1 json.RawMessage `json:"val1"` Val2 []json.RawMessage `json:"val2"` Val3 map[string]json.RawMessage `json:"val3"` } func Test_gconv_RawMessage(t *testing.T) { gtest.C(t, func(t *gtest.T) { ff := &tFF{} var tmp = map[string]any{ "val1": map[string]any{"hello": "world"}, "val2": []any{map[string]string{"hello": "world"}}, "val3": map[string]map[string]string{"val3": {"hello": "world"}}, } err := gconv.Struct(tmp, ff) t.AssertNil(err) t.AssertNE(ff, nil) t.Assert(ff.Val1, []byte(`{"hello":"world"}`)) t.AssertEQ(len(ff.Val2), 1) t.Assert(ff.Val2[0], []byte(`{"hello":"world"}`)) t.AssertEQ(len(ff.Val3), 1) t.Assert(ff.Val3["val3"], []byte(`{"hello":"world"}`)) }) }
all test passed
gconv.Struct prefer to use reflect.Type.Name() to get type name rather than reflect.Type.String().
gconv.Struct
reflect.Type.Name()
reflect.Type.String()
gf/util/gconv/gconv_struct.go
Lines 530 to 533 in 35e5f1f
reflect.Type(json.RawMessage).Name() should be RawMessage reflect.Type(json.RawMessage).String() should be json.RawMessage
reflect.Type(json.RawMessage).Name()
RawMessage
reflect.Type(json.RawMessage).String()
json.RawMessage
gf/util/gconv/gconv_convert.go
Lines 254 to 274 in 35e5f1f
so gconv_convert.go:272 case json.RawMessage should be replaced by case RawMessage, json.RawMessage
case json.RawMessage
case RawMessage, json.RawMessage
The text was updated successfully, but these errors were encountered:
fix: gconv struct slice/map of json.RawMessage (gogf#3006)
73e5d58
fix issue gconv struct slice/map of json.RawMessage (#3006) (#3008)
65192a7
No branches or pull requests
1. What version of
Go
and system type/arch are you using?go version go1.19.12 windows/amd64
2. What version of
GoFrame
are you using?v2.5.4
3. Can this issue be re-produced with the latest release?
Yes
4. What did you do?
5. What did you expect to see?
all test passed
6. What did you see instead?
gconv.Struct
prefer to usereflect.Type.Name()
to get type name rather thanreflect.Type.String()
.gf/util/gconv/gconv_struct.go
Lines 530 to 533 in 35e5f1f
reflect.Type(json.RawMessage).Name()
should beRawMessage
reflect.Type(json.RawMessage).String()
should bejson.RawMessage
gf/util/gconv/gconv_convert.go
Lines 254 to 274 in 35e5f1f
so gconv_convert.go:272
case json.RawMessage
should be replaced bycase RawMessage, json.RawMessage
The text was updated successfully, but these errors were encountered: