1 回答
TA贡献1804条经验 获得超3个赞
import "encoding/json"
type Group struct {
Id string `json:"id" db:"id"`
Title string `json:"title" db:"title"`
Collaborators UserList `json:"collaborators" db:"collaborators"`
}
type User struct {
Id string `json:"id" db:"id"`
FirstName string `json:"first_name" db:"first_name"`
LastName string `json:"last_name" db:"last_name"`
ProfilePhoto *string `json:"profile_photo" db:"user_pic_url"`
}
type UserList []User
func (list *UserList) Scan(src interface{}) error {
var data []byte
switch v := src.(type) {
case []byte:
data = v
case string:
data = []byte(v)
default:
return nil // or return some error
}
return json.Unmarshal(data, list)
}
- 1 回答
- 0 关注
- 246 浏览
添加回答
举报