1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/common/protocol/user_json.go
2016-09-18 00:41:21 +02:00

22 lines
403 B
Go

// +build json
package protocol
import "encoding/json"
func (u *User) UnmarshalJSON(data []byte) error {
type rawUser struct {
EmailString string `json:"email"`
LevelByte byte `json:"level"`
}
var rawUserValue rawUser
if err := json.Unmarshal(data, &rawUserValue); err != nil {
return err
}
u.Email = rawUserValue.EmailString
u.Level = uint32(rawUserValue.LevelByte)
return nil
}