有这样的结构:
Programs struct {
ID int `json:"id"`
ShortName string `json:"short_name"`
ProgramPoints float64 `json:"program_points"`
Countries []string `json:"countries"`
}
该列countries是 JSON 列,其中包含国家/地区["US","GB"] 解析数组:
stmt, err := db.Query(sql)
err = stmt.Scan(
&program.ID,
&program.ShortName,
&program.ProgramPoints,
&program.Countries)
有错误 unsupported Scan, storing driver.Value type []uint8 into type *[]string 我找到了如何将 JSON 对象解析为结构而不是数组的方法。提前感谢任何帮助
冉冉说
相关分类