【发布时间】:2022-01-18 18:19:07
【问题描述】:
我正在尝试将 json 字段插入 mysql。它给出了一个错误。在这里需要你的帮助。
我的示例代码类
type StringInterfaceMap map[string]interface{}
type Movie struct {
Id int
Name string
Casting StringInterfaceMap
Language string
Release_date time.Time
Rating float32
IsAbove18 bool
}
func buildBrowserData() map[string]interface{} {
return map[string]interface{}{
"Actor": "Rajinikanth", "Music": "Deva",
"resolution": struct {
X int json:"x"
Y int json:"y"
}{1920, 1080},
}
}
entry := model.Movie{
Id: 6,
Name: ctx.QueryParam("Name"),
Casting: buildBrowserData(),
Language: ctx.QueryParam("Language"),
Release_date: ctx.QueryParam("Release_date"),
Rating: 1,
IsAbove18: true,
}
在尝试插入上述入口模型时,在插入铸造类型时出现以下错误。 转换参数类型:不支持的类型 model.StringInterfaceMap, a map
【问题讨论】: