add module jsoniter && helper function for models
This commit is contained in:
parent
890fd036be
commit
aa90517c12
8
model.go
8
model.go
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue