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