v2ray-core/proxy/vmess/account_json.go

23 lines
383 B
Go
Raw Normal View History

2016-07-25 15:36:24 +00:00
// +build json
package vmess
import (
"encoding/json"
)
2016-10-12 16:43:55 +00:00
func (u *Account) UnmarshalJSON(data []byte) error {
2016-07-25 15:36:24 +00:00
type JsonConfig struct {
ID string `json:"id"`
AlterIds uint16 `json:"alterId"`
}
var rawConfig JsonConfig
if err := json.Unmarshal(data, &rawConfig); err != nil {
return err
}
2016-09-17 22:41:21 +00:00
u.Id = rawConfig.ID
u.AlterId = uint32(rawConfig.AlterIds)
2016-07-25 15:36:24 +00:00
return nil
}