// UnmarshalSession will unmarshal a JSON string into a session.
552977
func (p *Provider) UnmarshalSession(data string) (goth.Session, error) {
	s := Session{}
	err := json.Unmarshal([]byte(data), &s)
	return &s, err
}
773632
func (o *Instance) UnmarshalJSON(data []byte) error {
	var jsonName string
	if err := json.Unmarshal(data, &jsonName); err == nil {
		o.Name = &jsonName
		return nil
	}

	var r realInstance
	if err := json.Unmarshal(data, &r); err != nil {
		return err
	}
	*o = Instance(r)
	return nil
}
941070
func (v *ListMemberUploaded) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson692db02bDecodeGithubComMailgunMailgunGoEvents9(&r, v)
	return r.Error()
}
545876
func (u *User) UnmarshalJSON(data []byte) error {
	// Try to unmarshal data in a struct equal to User, we need it
	// to avoid infinite recursive call of this function
	type AliasUser User
	var au AliasUser
	err := json.Unmarshal(data, &au)
	if err == nil {
		*u = User(au)
		return nil
	}
	// Data type is not known, check if it is a json string
	// which contains a star, which is permitted in the spec
	var str string
	err = json.Unmarshal(data, &str)
	if err == nil {
		if str != "*" {
			return errors.New("unrecognized Principal field")
		}
		*u = User{AWS: set.CreateStringSet("*")}
		return nil
	}
	return err
}
272066
func (i *IAMPrincipal) UnmarshalJSON(data []byte) error {
	// Handle single string values like "*"
	var v string
	err := json.Unmarshal(data, &v)
	if err == nil {
		i.AWS = StringList(String(v))
		i.CanonicalUser = nil
		i.Federated = nil
		i.Service = nil
		return nil
	}

	// Handle all other values
	var v2 iamPrincipalCopy
	err = json.Unmarshal(data, &v2)
	if err != nil {
		return err
	}

	i.AWS = v2.AWS
	i.CanonicalUser = v2.CanonicalUser
	i.Federated = v2.Federated
	i.Service = v2.Service

	return nil
}
1223434
func (instance *ApplicationInstance) UnmarshalJSON(data []byte) error {
	var ccInstance struct {
		Details string  `json:"details"`
		Since   float64 `json:"since"`
		State   string  `json:"state"`
	}
	err := cloudcontroller.DecodeJSON(data, &ccInstance)
	if err != nil {
		return err
	}

	instance.Details = ccInstance.Details
	instance.State = constant.ApplicationInstanceState(ccInstance.State)
	instance.Since = ccInstance.Since

	return nil
}
336752
func (r *Request) UnmarshalJSON(rawData []byte) error {
	var requestJSON updateRequestJSON
	if err := json.Unmarshal(rawData, &requestJSON); err != nil {
		return err
	}
	return r.fromJSON(&requestJSON)
}
1037583
func (b *BareMetalServer) UnmarshalJSON(data []byte) error {
	if b == nil {
		*b = BareMetalServer{}
	}

	var fields map[string]interface{}
	if err := json.Unmarshal(data, &fields); err != nil {
		return err
	}

	value := fmt.Sprintf("%v", fields["cpu_count"])
	if len(value) == 0 || value == "<nil>" {
		value = "0"
	}
	cpu, err := strconv.ParseInt(value, 10, 64)
	if err != nil {
		return err
	}
	b.CPUs = int(cpu)

	value = fmt.Sprintf("%v", fields["DCID"])
	if len(value) == 0 || value == "<nil>" {
		value = "0"
	}
	region, err := strconv.ParseInt(value, 10, 64)
	if err != nil {
		return err
	}
	b.RegionID = int(region)

	value = fmt.Sprintf("%v", fields["METALPLANID"])
	if len(value) == 0 || value == "<nil>" {
		value = "0"
	}
	plan, err := strconv.ParseInt(value, 10, 64)
	if err != nil {
		return err
	}
	b.PlanID = int(plan)

	value = fmt.Sprintf("%v", fields["OSID"])
	if value == "<nil>" {
		value = ""
	}
	b.OSID = value

	value = fmt.Sprintf("%v", fields["APPID"])
	if value == "<nil>" || value == "0" {
		value = ""
	}
	b.AppID = value

	b.ID = fmt.Sprintf("%v", fields["SUBID"])
	b.Name = fmt.Sprintf("%v", fields["label"])
	b.OS = fmt.Sprintf("%v", fields["os"])
	b.RAM = fmt.Sprintf("%v", fields["ram"])
	b.Disk = fmt.Sprintf("%v", fields["disk"])
	b.MainIP = fmt.Sprintf("%v", fields["main_ip"])
	b.Location = fmt.Sprintf("%v", fields["location"])
	b.DefaultPassword = fmt.Sprintf("%v", fields["default_password"])
	b.Created = fmt.Sprintf("%v", fields["date_created"])
	b.Status = fmt.Sprintf("%v", fields["status"])
	b.NetmaskV4 = fmt.Sprintf("%v", fields["netmask_v4"])
	b.GatewayV4 = fmt.Sprintf("%v", fields["gateway_v4"])

	v6networks := make([]V6Network, 0)
	if networks, ok := fields["v6_networks"].([]interface{}); ok {
		for _, network := range networks {
			if network, ok := network.(map[string]interface{}); ok {
				v6network := V6Network{
					Network:     fmt.Sprintf("%v", network["v6_network"]),
					MainIP:      fmt.Sprintf("%v", network["v6_main_ip"]),
					NetworkSize: fmt.Sprintf("%v", network["v6_network_size"]),
				}
				v6networks = append(v6networks, v6network)
			}
		}
		b.V6Networks = v6networks
	}

	b.Tag = fmt.Sprintf("%v", fields["tag"])

	return nil
}
610387
func (o *ScalingGroup) UnmarshalJSON(data []byte) error {
	var jsonName string
	if err := json.Unmarshal(data, &jsonName); err == nil {
		o.Name = &jsonName
		return nil
	}

	var r realScalingGroup
	if err := json.Unmarshal(data, &r); err != nil {
		return err
	}
	*o = ScalingGroup(r)
	return nil
}
932963
func (j *JSONMarshaler) Unmarshal(data []byte, v interface{}) error {
	return json.Unmarshal(data, v)
}
900279
func (u *DeviceChangeIpDesktopDetails) UnmarshalJSON(b []byte) error {
	type wrap struct {
		// DeviceSessionInfo : Device's session logged information.
		DeviceSessionInfo json.RawMessage `json:"device_session_info"`
	}
	var w wrap
	if err := json.Unmarshal(b, &w); err != nil {
		return err
	}
	DeviceSessionInfo, err := IsDeviceSessionLogInfoFromJSON(w.DeviceSessionInfo)
	if err != nil {
		return err
	}
	u.DeviceSessionInfo = DeviceSessionInfo
	return nil
}
227186
func (v *JSONWriteBody) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson72863a49DecodeGithubComSignalfxMetricproxyProtocolCollectdFormat1(&r, v)
	return r.Error()
}
314286
func (aSpace *addrSpace) UnmarshalJSON(data []byte) error {
	aSpace.Lock()
	defer aSpace.Unlock()

	m := map[string]interface{}{}
	err := json.Unmarshal(data, &m)
	if err != nil {
		return err
	}

	aSpace.scope = datastore.LocalScope
	s := m["Scope"].(string)
	if s == string(datastore.GlobalScope) {
		aSpace.scope = datastore.GlobalScope
	}

	if v, ok := m["Subnets"]; ok {
		sb, _ := json.Marshal(v)
		var s map[string]*PoolData
		err := json.Unmarshal(sb, &s)
		if err != nil {
			return err
		}
		for ks, v := range s {
			k := SubnetKey{}
			k.FromString(ks)
			aSpace.subnets[k] = v
		}
	}

	return nil
}
803494
func (l *EMRInstanceGroupConfigEbsConfigurationList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := EMRInstanceGroupConfigEbsConfiguration{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = EMRInstanceGroupConfigEbsConfigurationList{item}
		return nil
	}
	list := []EMRInstanceGroupConfigEbsConfiguration{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = EMRInstanceGroupConfigEbsConfigurationList(list)
		return nil
	}
	return err
}
934373
func (level *Level) UnmarshalJSON(data []byte) error {
	var (
		s   string
		err error
	)
	if len(data) >= 2 {
		s, err = strconv.Unquote(string(data))
		if err != nil {
			return err
		}
	} else {
		s = string(data)
	}
	return level.Decode(s)
}
1313103
func (instance *ApplicationInstanceStatus) UnmarshalJSON(data []byte) error {
	var ccInstance struct {
		State            string `json:"state"`
		IsolationSegment string `json:"isolation_segment"`
		Stats            struct {
			Usage struct {
				Disk   int64   `json:"disk"`
				Memory int64   `json:"mem"`
				CPU    float64 `json:"cpu"`
			} `json:"usage"`
			MemoryQuota int64 `json:"mem_quota"`
			DiskQuota   int64 `json:"disk_quota"`
			Uptime      int64 `json:"uptime"`
		} `json:"stats"`
	}
	err := cloudcontroller.DecodeJSON(data, &ccInstance)
	if err != nil {
		return err
	}

	instance.CPU = ccInstance.Stats.Usage.CPU
	instance.Disk = ccInstance.Stats.Usage.Disk
	instance.DiskQuota = ccInstance.Stats.DiskQuota
	instance.IsolationSegment = ccInstance.IsolationSegment
	instance.Memory = ccInstance.Stats.Usage.Memory
	instance.MemoryQuota = ccInstance.Stats.MemoryQuota
	instance.State = constant.ApplicationInstanceState(ccInstance.State)
	instance.Uptime = ccInstance.Stats.Uptime

	return nil
}
192120
func (bz *HexBytes) UnmarshalJSON(data []byte) error {
	if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' {
		return fmt.Errorf("Invalid hex string: %s", data)
	}
	bz2, err := hex.DecodeString(string(data[1 : len(data)-1]))
	if err != nil {
		return err
	}
	*bz = bz2
	return nil
}