account_json.go 385 B

12345678910111213141516171819202122
  1. // +build json
  2. package vmess
  3. import (
  4. "encoding/json"
  5. )
  6. func (u *AccountPB) UnmarshalJSON(data []byte) error {
  7. type JsonConfig struct {
  8. ID string `json:"id"`
  9. AlterIds uint16 `json:"alterId"`
  10. }
  11. var rawConfig JsonConfig
  12. if err := json.Unmarshal(data, &rawConfig); err != nil {
  13. return err
  14. }
  15. u.Id = rawConfig.ID
  16. u.AlterId = uint32(rawConfig.AlterIds)
  17. return nil
  18. }