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"`
|
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 {
|
||||||
|
|
Loading…
Reference in New Issue