// implement Unmarshal interface
// required for "none" as lastupdated in unused sensor
198038
func (u *UpdateTime) UnmarshalJSON(b []byte) error {
	s := strings.Trim(string(b), "\"")
	if s == "none" {
		*u = UpdateTime{&time.Time{}}
		return nil
	}
	t, err := time.Parse("2006-01-02T15:04:05", s)
	if err != nil {
		return err
	}
	*u = UpdateTime{&t}
	return nil
}
1348103
func (rec *Recording) UnmarshalJSON(data []byte) error {
	var raw jsonRecording
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}
	createdAt, err := time.Parse(time.RFC3339, raw.CreatedAt)
	if err != nil {
		return fmt.Errorf("unable to parse Recording CreatedAt: %v", err)
	}
	updatedAt, err := time.Parse(time.RFC3339, raw.UpdatedAt)
	if err != nil {
		return fmt.Errorf("unable to parse Recording UpdatedAt: %v", err)
	}
	*rec = Recording{
		ID:        raw.ID,
		Format:    raw.Format,
		LegID:     raw.LegID,
		Status:    RecordingStatus(raw.Status),
		Duration:  time.Second * time.Duration(raw.Duration),
		CreatedAt: createdAt,
		UpdatedAt: updatedAt,
		links:     raw.Links,
	}
	return nil
}
1307787
func (ps *PeerRoundState) Unmarshal(bs []byte) error {
	return cdc.UnmarshalBinaryBare(bs, ps)
}
1097259
func (u *LinkedDeviceLogInfo) UnmarshalJSON(body []byte) error {
	type wrap struct {
		dropbox.Tagged
		// MobileDeviceSession : mobile device session's details.
		MobileDeviceSession json.RawMessage `json:"mobile_device_session,omitempty"`
		// DesktopDeviceSession : desktop device session's details.
		DesktopDeviceSession json.RawMessage `json:"desktop_device_session,omitempty"`
		// WebDeviceSession : web device session's details.
		WebDeviceSession json.RawMessage `json:"web_device_session,omitempty"`
		// LegacyDeviceSession : legacy device session's details.
		LegacyDeviceSession json.RawMessage `json:"legacy_device_session,omitempty"`
	}
	var w wrap
	var err error
	if err = json.Unmarshal(body, &w); err != nil {
		return err
	}
	u.Tag = w.Tag
	switch u.Tag {
	case "mobile_device_session":
		err = json.Unmarshal(body, &u.MobileDeviceSession)

		if err != nil {
			return err
		}
	case "desktop_device_session":
		err = json.Unmarshal(body, &u.DesktopDeviceSession)

		if err != nil {
			return err
		}
	case "web_device_session":
		err = json.Unmarshal(body, &u.WebDeviceSession)

		if err != nil {
			return err
		}
	case "legacy_device_session":
		err = json.Unmarshal(body, &u.LegacyDeviceSession)

		if err != nil {
			return err
		}
	}
	return nil
}
17279
func (m *MemSwapBytes) UnmarshalJSON(s []byte) error {
	b := MemBytes(*m)
	return b.UnmarshalJSON(s)
}
224088
func (s *Serializer) Unmarshal(data []byte, v interface{}) error {
	pb, ok := v.(proto.Message)
	if !ok {
		return constants.ErrWrongValueType
	}
	return proto.Unmarshal(data, pb)
}
1301226
func (m *MonitorValue) UnmarshalJSON(data []byte) error {
	targetData := strings.Replace(strings.Replace(string(data), " ", "", -1), "\n", "", -1)
	if targetData == `[]` {
		return nil
	}

	tmp := &struct {
		CPUTime           *float64 `json:"CPU-TIME,omitempty"`
		Write             *float64 `json:",omitempty"`
		Read              *float64 `json:",omitempty"`
		Receive           *float64 `json:",omitempty"`
		Send              *float64 `json:",omitempty"`
		In                *float64 `json:",omitempty"`
		Out               *float64 `json:",omitempty"`
		TotalMemorySize   *float64 `json:"Total-Memory-Size,omitempty"`
		UsedMemorySize    *float64 `json:"Used-Memory-Size,omitempty"`
		TotalDisk1Size    *float64 `json:"Total-Disk1-Size,omitempty"`
		UsedDisk1Size     *float64 `json:"Used-Disk1-Size,omitempty"`
		TotalDisk2Size    *float64 `json:"Total-Disk2-Size,omitempty"`
		UsedDisk2Size     *float64 `json:"Used-Disk2-Size,omitempty"`
		BinlogUsedSizeKiB *float64 `json:"binlogUsedSizeKiB,omitempty"`
		DelayTimeSec      *float64 `json:"delayTimeSec,omitempty"`
		FreeDiskSize      *float64 `json:"Free-Disk-Size,omitempty"`
		ResponseTimeSec   *float64 `json:"responsetimesec,omitempty"`
		UplinkBPS         *float64 `json:"UplinkBps,omitempty"`
		DownlinkBPS       *float64 `json:"DownlinkBps,omitempty"`
		ActiveConnections *float64 `json:"activeConnections,omitempty"`
		ConnectionsPerSec *float64 `json:"connectionsPerSec,omitempty"`
	}{}
	if err := json.Unmarshal(data, &tmp); err != nil {
		return err
	}

	m.CPUTime = tmp.CPUTime
	m.Write = tmp.Write
	m.Read = tmp.Read
	m.Receive = tmp.Receive
	m.Send = tmp.Send
	m.In = tmp.In
	m.Out = tmp.Out
	m.TotalMemorySize = tmp.TotalMemorySize
	m.UsedMemorySize = tmp.UsedMemorySize
	m.TotalDisk1Size = tmp.TotalDisk1Size
	m.UsedDisk1Size = tmp.UsedDisk1Size
	m.TotalDisk2Size = tmp.TotalDisk2Size
	m.UsedDisk2Size = tmp.UsedDisk2Size
	m.BinlogUsedSizeKiB = tmp.BinlogUsedSizeKiB
	m.DelayTimeSec = tmp.DelayTimeSec
	m.FreeDiskSize = tmp.FreeDiskSize
	m.ResponseTimeSec = tmp.ResponseTimeSec
	m.UplinkBPS = tmp.UplinkBPS
	m.DownlinkBPS = tmp.DownlinkBPS
	m.ActiveConnections = tmp.ActiveConnections
	m.ConnectionsPerSec = tmp.ConnectionsPerSec

	return nil
}
135845
func (v *BodySendFormatV2) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson3b0ebf6aDecodeGithubComSignalfxGatewayProtocolSignalfxFormat7(&r, v)
	return r.Error()
}
809969
func Unmarshal(b []byte) (orb.Geometry, error) {
	g, err := NewDecoder(bytes.NewReader(b)).Decode()
	if err == io.EOF || err == io.ErrUnexpectedEOF {
		return nil, ErrNotWKB
	}

	return g, err
}
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
}
806399
func (t *TeleportClusterConfigMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (ClusterConfig, error) {
	var clusterConfig ClusterConfigV3

	if len(bytes) == 0 {
		return nil, trace.BadParameter("missing resource data")
	}

	cfg, err := collectOptions(opts)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	if cfg.SkipValidation {
		if err := utils.FastUnmarshal(bytes, &clusterConfig); err != nil {
			return nil, trace.BadParameter(err.Error())
		}
	} else {
		err = utils.UnmarshalWithSchema(GetClusterConfigSchema(""), &clusterConfig, bytes)
		if err != nil {
			return nil, trace.BadParameter(err.Error())
		}
	}

	err = clusterConfig.CheckAndSetDefaults()
	if err != nil {
		return nil, trace.Wrap(err)
	}

	if cfg.ID != 0 {
		clusterConfig.SetResourceID(cfg.ID)
	}
	if !cfg.Expires.IsZero() {
		clusterConfig.SetExpiry(cfg.Expires)
	}
	return &clusterConfig, nil
}
502521
func (x *Communication) UnmarshalJSON(data []byte) (err error) {
	x2 := communication{}
	if err = json.Unmarshal(data, &x2); err == nil {
		if x2.Contained != nil {
			for i := range x2.Contained {
				x2.Contained[i] = MapToResource(x2.Contained[i], true)
			}
		}
		*x = Communication(x2)
		return x.checkResourceType()
	}
	return
}
360107
func (p *StateInitializationParams) Unmarshal(data []byte) error {
	var internal stateInitializationParamsInternal
	if err := yaml.Unmarshal(data, &internal); err != nil {
		return errors.Annotate(err, "unmarshalling state initialization params")
	}
	var imageMetadata []*imagemetadata.ImageMetadata
	if err := json.Unmarshal([]byte(internal.CustomImageMetadataJSON), &imageMetadata); err != nil {
		return errors.Trace(err)
	}
	cfg, err := config.New(config.NoDefaults, internal.ControllerModelConfig)
	if err != nil {
		return errors.Trace(err)
	}
	controllerCloud, err := cloud.UnmarshalCloud([]byte(internal.ControllerCloud))
	if err != nil {
		return errors.Trace(err)
	}
	*p = StateInitializationParams{
		ControllerConfig:                        internal.ControllerConfig,
		ControllerModelConfig:                   cfg,
		ControllerModelEnvironVersion:           internal.ControllerModelEnvironVersion,
		ControllerInheritedConfig:               internal.ControllerInheritedConfig,
		RegionInheritedConfig:                   internal.RegionInheritedConfig,
		HostedModelConfig:                       internal.HostedModelConfig,
		BootstrapMachineInstanceId:              internal.BootstrapMachineInstanceId,
		BootstrapMachineConstraints:             internal.BootstrapMachineConstraints,
		BootstrapMachineHardwareCharacteristics: internal.BootstrapMachineHardwareCharacteristics,
		ModelConstraints:                        internal.ModelConstraints,
		CustomImageMetadata:                     imageMetadata,
		ControllerCloud:                         controllerCloud,
		ControllerCloudRegion:                   internal.ControllerCloudRegion,
		ControllerCloudCredentialName:           internal.ControllerCloudCredentialName,
		ControllerCloudCredential:               internal.ControllerCloudCredential,
	}
	return nil
}
992856
func (x *BundleEntryComponent) UnmarshalJSON(data []byte) (err error) {
	x2 := bundleEntryComponent{}
	if err = json.Unmarshal(data, &x2); err == nil {
		if x2.Resource != nil {
			x2.Resource = MapToResource(x2.Resource, true)
		}
		*x = BundleEntryComponent(x2)
	}
	return
}
153533
func (n *DevNonce) Unmarshal(data []byte) error {
	*n = [2]byte{} // Reset the receiver
	return n.UnmarshalBinary(data)
}
91239
func recoverUnmarshal(v interface{}, data *C.pn_data_t) (err error) {
	defer func() {
		if r := recover(); r != nil {
			if uerr, ok := r.(*UnmarshalError); ok {
				err = uerr
			} else {
				panic(r)
			}
		}
	}()
	unmarshal(v, data)
	return nil
}
913855
func Unmarshal(data []byte, target interface{}) error {
	if target == nil {
		return errors.New("target must not be nil")
	}

	if reflect.TypeOf(target).Kind() != reflect.Ptr {
		return errors.New("target must be a ptr")
	}

	ctx := &Document{}

	err := json.Unmarshal(data, ctx)
	if err != nil {
		return err
	}

	if ctx.Data == nil {
		return errors.New(`Source JSON is empty and has no "attributes" payload object`)
	}

	if ctx.Data.DataObject != nil {
		return setDataIntoTarget(ctx.Data.DataObject, target)
	}

	if ctx.Data.DataArray != nil {
		targetSlice := reflect.TypeOf(target).Elem()
		if targetSlice.Kind() != reflect.Slice {
			return fmt.Errorf("Cannot unmarshal array to struct target %s", targetSlice)
		}
		targetType := targetSlice.Elem()
		targetPointer := reflect.ValueOf(target)
		targetValue := targetPointer.Elem()

		for _, record := range ctx.Data.DataArray {
			// check if there already is an entry with the same id in target slice,
			// otherwise create a new target and append
			var targetRecord, emptyValue reflect.Value
			for i := 0; i < targetValue.Len(); i++ {
				marshalCasted, ok := targetValue.Index(i).Interface().(MarshalIdentifier)
				if !ok {
					return errors.New("existing structs must implement interface MarshalIdentifier")
				}
				if record.ID == marshalCasted.GetID() {
					targetRecord = targetValue.Index(i).Addr()
					break
				}
			}

			if targetRecord == emptyValue || targetRecord.IsNil() {
				targetRecord = reflect.New(targetType)
				err := setDataIntoTarget(&record, targetRecord.Interface())
				if err != nil {
					return err
				}
				targetValue = reflect.Append(targetValue, targetRecord.Elem())
			} else {
				err := setDataIntoTarget(&record, targetRecord.Interface())
				if err != nil {
					return err
				}
			}
		}

		targetPointer.Elem().Set(targetValue)
	}

	return nil
}