// Deserialize takes some JSON serialized bytes and unmarshals them as
// cpufreq.Frequency.
175280
func Deserialize(p []byte) (*freq.Frequency, error) {
	f := &freq.Frequency{}
	err := json.Unmarshal(p, f)
	if err != nil {
		return nil, err
	}
	return f, nil
}
141433
func Deserialize(p []byte) *processors.Processors {
	flatP := structs.GetRootAsProcessors(p, 0)
	procs := &processors.Processors{}
	flatCache := &structs.CacheInf{}
	procs.Timestamp = flatP.Timestamp()
	procs.Architecture = string(flatP.Architecture())
	procs.CPUs = flatP.CPUs()
	procs.Possible = string(flatP.Possible())
	procs.Present = string(flatP.Present())
	procs.Offline = string(flatP.Offline())
	procs.Online = string(flatP.Online())
	procs.Sockets = flatP.Sockets()
	procs.CoresPerSocket = flatP.CoresPerSocket()
	procs.ThreadsPerCore = flatP.ThreadsPerCore()
	procs.VendorID = string(flatP.VendorID())
	procs.CPUFamily = string(flatP.CPUFamily())
	procs.Model = string(flatP.Model())
	procs.ModelName = string(flatP.ModelName())
	procs.Stepping = string(flatP.Stepping())
	procs.Microcode = string(flatP.Microcode())
	procs.CPUMHz = flatP.CPUMHz()
	procs.MHzMin = flatP.MHzMin()
	procs.MHzMax = flatP.MHzMax()
	procs.BogoMIPS = flatP.BogoMIPS()
	procs.CacheSize = string(flatP.CacheSize())
	procs.CacheIDs = make([]string, 0, flatP.CacheLength())
	procs.Cache = make(map[string]string, flatP.CacheLength())
	for j := 0; j < flatP.CacheLength(); j++ {
		if !flatP.Cache(flatCache, j) {
			continue
		}
		procs.CacheIDs = append(procs.CacheIDs, string(flatCache.ID()))
		procs.Cache[procs.CacheIDs[j]] = string(flatCache.Size())
	}
	procs.Flags = make([]string, flatP.FlagsLength())
	for i := 0; i < len(procs.Flags); i++ {
		procs.Flags[i] = string(flatP.Flags(i))
	}
	procs.Bugs = make([]string, flatP.BugsLength())
	for i := 0; i < len(procs.Bugs); i++ {
		procs.Bugs[i] = string(flatP.Bugs(i))
	}
	procs.OpModes = make([]string, flatP.OpModesLength())
	for i := 0; i < len(procs.OpModes); i++ {
		procs.OpModes[i] = string(flatP.OpModes(i))
	}
	procs.Virtualization = string(flatP.Virtualization())
	procs.NumaNodes = flatP.NumaNodes()
	var n structs.Node
	procs.NumaNodeCPUs = make([]node.Node, flatP.NumaNodeCPUsLength())
	for i := 0; i < len(procs.NumaNodeCPUs); i++ {
		if !flatP.NumaNodeCPUs(&n, i) {
			continue
		}
		procs.NumaNodeCPUs[i].ID = n.ID()
		procs.NumaNodeCPUs[i].CPUList = string(n.CPUList())
	}
	return procs
}
473768
func (j JSONPBStateSerializer) Deserialize(serialized string, state interface{}) error {
	pm, ok := state.(proto.Message)
	if ok {
		return j.u.Unmarshal(strings.NewReader(serialized), pm)
	}
	return j.fbss.Deserialize(serialized, state)
}
124365
func Deserialize(p []byte) *mem.Info {
	infoFlat := structs.GetRootAsInfo(p, 0)
	info := &mem.Info{}
	info.Timestamp = infoFlat.Timestamp()
	info.Active = infoFlat.Active()
	info.ActiveAnon = infoFlat.ActiveAnon()
	info.ActiveFile = infoFlat.ActiveFile()
	info.AnonHugePages = infoFlat.AnonHugePages()
	info.AnonPages = infoFlat.AnonPages()
	info.Bounce = infoFlat.Bounce()
	info.Buffers = infoFlat.Buffers()
	info.Cached = infoFlat.Cached()
	info.CommitLimit = infoFlat.CommitLimit()
	info.CommittedAS = infoFlat.CommittedAS()
	info.DirectMap4K = infoFlat.DirectMap4K()
	info.DirectMap2M = infoFlat.DirectMap2M()
	info.Dirty = infoFlat.Dirty()
	info.HardwareCorrupted = infoFlat.HardwareCorrupted()
	info.HugePagesFree = infoFlat.HugePagesFree()
	info.HugePagesRsvd = infoFlat.HugePagesRsvd()
	info.HugePagesSize = infoFlat.HugePagesSize()
	info.HugePagesSurp = infoFlat.HugePagesSurp()
	info.HugePagesTotal = infoFlat.HugePagesTotal()
	info.Inactive = infoFlat.Inactive()
	info.InactiveAnon = infoFlat.InactiveAnon()
	info.InactiveFile = infoFlat.InactiveFile()
	info.KernelStack = infoFlat.KernelStack()
	info.Mapped = infoFlat.Mapped()
	info.MemAvailable = infoFlat.MemAvailable()
	info.MemFree = infoFlat.MemFree()
	info.MemTotal = infoFlat.MemTotal()
	info.Mlocked = infoFlat.Mlocked()
	info.NFSUnstable = infoFlat.NFSUnstable()
	info.PageTables = infoFlat.PageTables()
	info.Shmem = infoFlat.Shmem()
	info.Slab = infoFlat.Slab()
	info.SReclaimable = infoFlat.SReclaimable()
	info.SUnreclaim = infoFlat.SUnreclaim()
	info.SwapCached = infoFlat.SwapCached()
	info.SwapFree = infoFlat.SwapFree()
	info.SwapTotal = infoFlat.SwapTotal()
	info.Unevictable = infoFlat.Unevictable()
	info.VmallocChunk = infoFlat.VmallocChunk()
	info.VmallocTotal = infoFlat.VmallocTotal()
	info.VmallocUsed = infoFlat.VmallocUsed()
	info.Writeback = infoFlat.Writeback()
	info.WritebackTmp = infoFlat.WritebackTmp()
	return info
}
204922
func Serialize(proc *procs.Processors) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(proc)
}
308131
func Deserialize(p []byte) (*m.MemInfo, error) {
	var inf m.MemInfo
	err := json.Unmarshal(p, &inf)
	if err != nil {
		return nil, err
	}
	return &inf, nil
}
866144
func Deserialize(byt []byte, ptr interface{}) (err error) {
	if data, ok := ptr.(*[]byte); ok {
		*data = byt
		return
	}

	if v := reflect.ValueOf(ptr); v.Kind() == reflect.Ptr {
		switch p := v.Elem(); p.Kind() {
		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
			var i int64
			i, err = strconv.ParseInt(string(byt), 10, 64)
			if err != nil {
				cacheLog.Error("Deserialize: failed to parse int", "value", string(byt), "error", err)
			} else {
				p.SetInt(i)
			}
			return

		case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
			var i uint64
			i, err = strconv.ParseUint(string(byt), 10, 64)
			if err != nil {
				cacheLog.Error("Deserialize: failed to parse uint", "value", string(byt), "error", err)
			} else {
				p.SetUint(i)
			}
			return
		}
	}

	b := bytes.NewBuffer(byt)
	decoder := gob.NewDecoder(b)
	if err = decoder.Decode(ptr); err != nil {
		cacheLog.Error("Deserialize: glob decoding failed", "error", err)
		return
	}
	return
}
199151
func Serialize(cpus *cpux.CPUs) (p []byte) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std = NewProfiler()
	}
	return std.Serialize(cpus)
}
485701
func (ms *messageSerializer) deserialize(event []byte, websocketMessage []byte) (interface{}, error) {
	dataStartIdx := ms.prefixAndSepIdx + len(event) + 3
	if len(websocketMessage) <= dataStartIdx {
		return nil, errors.New("websocket invalid message: " + string(websocketMessage))
	}

	typ, err := strconv.Atoi(string(websocketMessage[ms.prefixAndSepIdx+len(event)+1 : ms.prefixAndSepIdx+len(event)+2])) // in order to iris-websocket-message;user;-> 4
	if err != nil {
		return nil, err
	}

	data := websocketMessage[dataStartIdx:] // in order to iris-websocket-message;user;4; -> themarshaledstringfromajsonstruct

	switch messageType(typ) {
	case messageTypeString:
		return string(data), nil
	case messageTypeInt:
		msg, err := strconv.Atoi(string(data))
		if err != nil {
			return nil, err
		}
		return msg, nil
	case messageTypeBool:
		if bytes.Equal(data, boolTrueB) {
			return true, nil
		}
		return false, nil
	case messageTypeBytes:
		return data, nil
	case messageTypeJSON:
		var msg interface{}
		err := json.Unmarshal(data, &msg)
		return msg, err
	default:
		return nil, errInvalidTypeMessage.Format(messageType(typ).Name(), websocketMessage)
	}
}
324769
func Deserialize(p []byte) (*stats.CPUStats, error) {
	st := &stats.CPUStats{}
	err := json.Unmarshal(p, st)
	if err != nil {
		return nil, err
	}
	return st, nil
}
922743
func deserialize(token string) (*tokenserver.MachineTokenEnvelope, *tokenserver.MachineTokenBody, error) {
	tokenBinBlob, err := base64.RawStdEncoding.DecodeString(token)
	if err != nil {
		return nil, nil, err
	}
	envelope := &tokenserver.MachineTokenEnvelope{}
	if err := proto.Unmarshal(tokenBinBlob, envelope); err != nil {
		return nil, nil, err
	}
	body := &tokenserver.MachineTokenBody{}
	if err := proto.Unmarshal(envelope.TokenBody, body); err != nil {
		return envelope, nil, err
	}
	return envelope, body, nil
}
533615
func Deserialize(p []byte) (*procs.Processors, error) {
	proc := &procs.Processors{}
	err := json.Unmarshal(p, proc)
	if err != nil {
		return nil, err
	}
	return proc, nil
}
1154646
func (prof *Profiler) Serialize(stts *stats.CPUStats) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	cpusF := make([]fb.UOffsetT, len(stts.CPU))
	ids := make([]fb.UOffsetT, len(stts.CPU))
	for i := 0; i < len(ids); i++ {
		ids[i] = prof.Builder.CreateString(stts.CPU[i].ID)
	}
	for i := 0; i < len(cpusF); i++ {
		structs.CPUStart(prof.Builder)
		structs.CPUAddID(prof.Builder, ids[i])
		structs.CPUAddUser(prof.Builder, stts.CPU[i].User)
		structs.CPUAddNice(prof.Builder, stts.CPU[i].Nice)
		structs.CPUAddSystem(prof.Builder, stts.CPU[i].System)
		structs.CPUAddIdle(prof.Builder, stts.CPU[i].Idle)
		structs.CPUAddIOWait(prof.Builder, stts.CPU[i].IOWait)
		structs.CPUAddIRQ(prof.Builder, stts.CPU[i].IRQ)
		structs.CPUAddSoftIRQ(prof.Builder, stts.CPU[i].SoftIRQ)
		structs.CPUAddSteal(prof.Builder, stts.CPU[i].Steal)
		structs.CPUAddQuest(prof.Builder, stts.CPU[i].Quest)
		structs.CPUAddQuestNice(prof.Builder, stts.CPU[i].QuestNice)
		cpusF[i] = structs.CPUEnd(prof.Builder)
	}
	structs.CPUStatsStartCPUVector(prof.Builder, len(cpusF))
	for i := len(cpusF) - 1; i >= 0; i-- {
		prof.Builder.PrependUOffsetT(cpusF[i])
	}
	cpusV := prof.Builder.EndVector(len(cpusF))
	structs.CPUStatsStart(prof.Builder)
	structs.CPUStatsAddClkTck(prof.Builder, stts.ClkTck)
	structs.CPUStatsAddTimestamp(prof.Builder, stts.Timestamp)
	structs.CPUStatsAddCtxt(prof.Builder, stts.Ctxt)
	structs.CPUStatsAddBTime(prof.Builder, stts.BTime)
	structs.CPUStatsAddProcesses(prof.Builder, stts.Processes)
	structs.CPUStatsAddCPU(prof.Builder, cpusV)
	prof.Builder.Finish(structs.CPUStatsEnd(prof.Builder))
	p := prof.Builder.Bytes[prof.Builder.Head():]
	// copy them (otherwise gets lost in reset)
	tmp := make([]byte, len(p))
	copy(tmp, p)
	return tmp
}
26473
func Deserialize(data []byte) (*Key, error) {
	if len(data) != 82 {
		return nil, ErrSerializedKeyWrongSize
	}
	var key = &Key{}
	key.Version = data[0:4]
	key.Depth = data[4]
	key.FingerPrint = data[5:9]
	key.ChildNumber = data[9:13]
	key.ChainCode = data[13:45]

	if data[45] == byte(0) {
		key.IsPrivate = true
		key.Key = data[46:78]
	} else {
		key.IsPrivate = false
		key.Key = data[45:78]
	}

	// validate checksum
	cs1, err := checksum(data[0 : len(data)-4])
	if err != nil {
		return nil, err
	}

	cs2 := data[len(data)-4:]
	for i := range cs1 {
		if cs1[i] != cs2[i] {
			return nil, ErrInvalidChecksum
		}
	}
	return key, nil
}
241784
func UnJSONBytes(b []byte, v ...interface{}) (interface{}, error) {
	if len(v) == 0 {
		var res interface{}
		err := ffjson.NewDecoder().Decode(b, &res)
		return res, err
	}
	err := ffjson.NewDecoder().Decode(b, &v[0])
	return v[0], err
}
1151298
func Deserialize(p []byte) (la l.LoadAvg, err error) {
	err = json.Unmarshal(p, &la)
	if err != nil {
		return la, err
	}
	return la, nil
}
1248939
func Deserialize(p []byte) (*o.OS, error) {
	os := &o.OS{}
	err := json.Unmarshal(p, os)
	if err != nil {
		return nil, err
	}
	return os, nil
}