fix parse data

This commit is contained in:
namhq1989 2023-01-16 08:42:26 +07:00
parent 99eb6e229a
commit 9e59daa977
1 changed files with 4 additions and 4 deletions

View File

@ -24,10 +24,10 @@ type User struct {
Avatar *FilePhoto `json:"avatar"`
}
func ParseToUser(data interface{}, result User) (err error) {
func ParseToUser(data interface{}, result *User) (err error) {
b := InterfaceToBytes(data)
if len(b) > 0 {
err = json.Unmarshal(b, &result)
err = json.Unmarshal(b, result)
} else {
err = errors.New("[natsio.ParseUser] cannot read data")
}
@ -56,10 +56,10 @@ type FileDimensions struct {
Medium *FileSize `json:"md"`
}
func ParseToPhoto(data interface{}, result FilePhoto) (err error) {
func ParseToPhoto(data interface{}, result *FilePhoto) (err error) {
b := InterfaceToBytes(data)
if len(b) > 0 {
err = json.Unmarshal(b, &result)
err = json.Unmarshal(b, result)
} else {
err = errors.New("[natsio.ParsePhoto] cannot read data")
}