mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 12:47:50 +08:00
This commit is contained in:
parent
467a5c1093
commit
448df14860
@ -266,10 +266,10 @@ func doConvert(in doConvertInput) (convertedValue interface{}) {
|
||||
case "map[string]string":
|
||||
return MapStrStr(in.FromValue)
|
||||
|
||||
case "map[string]interface{}":
|
||||
case "map[string]interface {}":
|
||||
return Map(in.FromValue)
|
||||
|
||||
case "[]map[string]interface{}":
|
||||
case "[]map[string]interface {}":
|
||||
return Maps(in.FromValue)
|
||||
|
||||
case "RawMessage", "json.RawMessage":
|
||||
|
@ -7,6 +7,7 @@
|
||||
package gconv_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
@ -366,3 +367,23 @@ func TestIssue3006(t *testing.T) {
|
||||
t.Assert(ff.Val3["val3"], []byte(`{"hello":"world"}`))
|
||||
})
|
||||
}
|
||||
|
||||
// https://github.com/gogf/gf/issues/3731
|
||||
func TestIssue3731(t *testing.T) {
|
||||
type Data struct {
|
||||
Doc map[string]interface{} `json:"doc"`
|
||||
}
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
dataMap := map[string]any{
|
||||
"doc": map[string]any{
|
||||
"craft": nil,
|
||||
},
|
||||
}
|
||||
|
||||
var args Data
|
||||
err := gconv.Struct(dataMap, &args)
|
||||
t.AssertNil(err)
|
||||
t.AssertEQ("<nil>", fmt.Sprintf("%T", args.Doc["craft"]))
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user