add module jsoniter && helper function for models

This commit is contained in:
Nam Huynh 2023-01-03 15:29:47 +07:00
parent 890fd036be
commit aa90517c12
1 changed files with 4 additions and 4 deletions

View File

@ -26,8 +26,8 @@ type User struct {
Avatar *FilePhoto `json:"avatar"` Avatar *FilePhoto `json:"avatar"`
} }
func ParseUser(user User, result interface{}) (err error) { func ParseToUser(data interface{}, result User) (err error) {
b := InterfaceToBytes(user) b := InterfaceToBytes(data)
if len(b) > 0 { if len(b) > 0 {
err = json.Unmarshal(b, &result) err = json.Unmarshal(b, &result)
} else { } else {
@ -58,8 +58,8 @@ type FileDimensions struct {
Medium *FileSize `json:"md"` Medium *FileSize `json:"md"`
} }
func ParsePhoto(photo FilePhoto, result interface{}) (err error) { func ParseToPhoto(data interface{}, result FilePhoto) (err error) {
b := InterfaceToBytes(photo) b := InterfaceToBytes(data)
if len(b) > 0 { if len(b) > 0 {
err = json.Unmarshal(b, &result) err = json.Unmarshal(b, &result)
} else { } else {