mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-18 10:26:01 -05:00
22 lines
406 B
Go
22 lines
406 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 = UserLevel(rawUserValue.LevelByte)
|
|
|
|
return nil
|
|
}
|