// Serialize to JSON. Will err if there are unmarshalable key values
976037
func (s JSONSerializer) Serialize(ss *sessions.Session) ([]byte, error) {
	m := make(map[string]interface{}, len(ss.Values))
	for k, v := range ss.Values {
		ks, ok := k.(string)
		if !ok {
			err := fmt.Errorf("Non-string key value, cannot serialize session to JSON: %v", k)
			fmt.Printf("redistore.JSONSerializer.serialize() Error: %v", err)
			return nil, err
		}
		m[ks] = v
	}
	return json.Marshal(m)
}
115764
func (u *User) Serialize() ([]byte, error) {
	serializedIdentity := &pb_msp.SerializedIdentity{
		Mspid:   u.mspID,
		IdBytes: u.enrollmentCertificate,
	}
	identity, err := proto.Marshal(serializedIdentity)
	if err != nil {
		return nil, errors.Wrap(err, "marshal serializedIdentity failed")
	}
	return identity, nil
}
418607
func (prof *Profiler) Serialize(inf *info.CPUInfo) ([]byte, error) {
	return json.Marshal(inf)
}
364125
func (prof *Profiler) Serialize(st *structs.DiskStats) ([]byte, error) {
	return json.Marshal(st)
}
1148361
func (t Version) JSON() (output string, err error) {
	var raw []byte
	ver := Get()
	if raw, err = json.MarshalIndent(ver, "", "\t"); err != nil {
		return
	}
	return string(raw), nil
}
1214270
func (e GobEncoder) Serialize(src interface{}) ([]byte, error) {
	buf := new(bytes.Buffer)
	enc := gob.NewEncoder(buf)
	if err := enc.Encode(src); err != nil {
		return nil, cookieError{cause: err, typ: usageError}
	}
	return buf.Bytes(), nil
}
414707
func (prof *Profiler) Serialize(stts *structs.DiskStats) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	devF := make([]fb.UOffsetT, len(stts.Device))
	names := make([]fb.UOffsetT, len(stts.Device))
	for i := 0; i < len(names); i++ {
		names[i] = prof.Builder.CreateString(stts.Device[i].Name)
	}
	for i := 0; i < len(devF); i++ {
		flat.DeviceStart(prof.Builder)
		flat.DeviceAddMajor(prof.Builder, stts.Device[i].Major)
		flat.DeviceAddMinor(prof.Builder, stts.Device[i].Minor)
		flat.DeviceAddName(prof.Builder, names[i])
		flat.DeviceAddReadsCompleted(prof.Builder, stts.Device[i].ReadsCompleted)
		flat.DeviceAddReadsMerged(prof.Builder, stts.Device[i].ReadsMerged)
		flat.DeviceAddReadSectors(prof.Builder, stts.Device[i].ReadSectors)
		flat.DeviceAddReadingTime(prof.Builder, stts.Device[i].ReadingTime)
		flat.DeviceAddWritesCompleted(prof.Builder, stts.Device[i].WritesCompleted)
		flat.DeviceAddWritesMerged(prof.Builder, stts.Device[i].WritesMerged)
		flat.DeviceAddWrittenSectors(prof.Builder, stts.Device[i].WrittenSectors)
		flat.DeviceAddWritingTime(prof.Builder, stts.Device[i].WritingTime)
		flat.DeviceAddIOInProgress(prof.Builder, stts.Device[i].IOInProgress)
		flat.DeviceAddIOTime(prof.Builder, stts.Device[i].IOTime)
		flat.DeviceAddWeightedIOTime(prof.Builder, stts.Device[i].WeightedIOTime)
		devF[i] = flat.DeviceEnd(prof.Builder)
	}
	flat.DiskStatsStartDeviceVector(prof.Builder, len(devF))
	for i := len(devF) - 1; i >= 0; i-- {
		prof.Builder.PrependUOffsetT(devF[i])
	}
	devV := prof.Builder.EndVector(len(devF))
	flat.DiskStatsStart(prof.Builder)
	flat.DiskStatsAddTimestamp(prof.Builder, stts.Timestamp)
	flat.DiskStatsAddDevice(prof.Builder, devV)
	prof.Builder.Finish(flat.DiskStatsEnd(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
}
237811
func Serialize(st *structs.DiskStats) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(st)
}
859889
func (b *NexthopRegisterBody) Serialize(version uint8) ([]byte, error) {
	buf := make([]byte, 0)

	// List of Registered Nexthops
	for _, nh := range b.Nexthops {
		nhBuf, err := nh.Serialize()
		if err != nil {
			return nil, err
		}
		buf = append(buf, nhBuf...)
	}

	return buf, nil
}
944026
func serializeToMap(v interface{}) map[string]interface{} {
	data, err := json.Marshal(v)
	if err != nil {
		logger.Criticalf("serializeToMap: marshal to json failed: %v", err)
		return nil
	}

	var asMap map[string]interface{}
	err = json.Unmarshal(data, &asMap)
	if err != nil {
		logger.Criticalf("serializeToMap: unmarshal to map failed: %v", err)
		return nil
	}

	return asMap
}
823007
func (prof *Profiler) Serialize(la l.LoadAvg) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	structs.LoadAvgStart(prof.Builder)
	structs.LoadAvgAddTimestamp(prof.Builder, la.Timestamp)
	structs.LoadAvgAddMinute(prof.Builder, la.Minute)
	structs.LoadAvgAddFive(prof.Builder, la.Five)
	structs.LoadAvgAddFifteen(prof.Builder, la.Fifteen)
	structs.LoadAvgAddRunning(prof.Builder, la.Running)
	structs.LoadAvgAddTotal(prof.Builder, la.Total)
	structs.LoadAvgAddPID(prof.Builder, la.PID)
	prof.Builder.Finish(structs.LoadAvgEnd(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
}
803406
func (ks *Keys) UnmarshalJSON(data []byte) error {
	parsed := make(map[string]TUFKey)
	err := json.Unmarshal(data, &parsed)
	if err != nil {
		return err
	}
	final := make(map[string]PublicKey)
	for k, tk := range parsed {
		final[k] = typedPublicKey(tk)
	}
	*ks = final
	return nil
}
644882
func (b *BaseKvdb) SerializeAll(kvps kvdb.KVPairs) ([]byte, error) {
	out, err := json.Marshal(kvps)
	if err != nil {
		return nil, err
	}
	return out, nil
}
197296
func (b *HttpRequest) ToJson(v interface{}) error {
	data, err := b.Bytes()
	if err != nil {
		return err
	}
	return json.Unmarshal(data, v)
}
1208624
func Serialize(w io.Writer, key []byte, rand io.Reader, passphrase []byte, c *Config) error {
	var buf [11]byte
	buf[0] = 3 /* iterated and salted */
	buf[1], _ = HashToHashId(c.hash())
	salt := buf[2:10]
	if _, err := io.ReadFull(rand, salt); err != nil {
		return err
	}
	encodedCount := c.encodedCount()
	count := decodeCount(encodedCount)
	buf[10] = encodedCount
	if _, err := w.Write(buf[:]); err != nil {
		return err
	}

	Iterated(key, c.hash().New(), passphrase, salt, count)
	return nil
}
1030770
func (a *Authenticator) Serialize(context.Context, oauth2.Principal) (string, error) {
	return a.Serialized, nil
}
596170
func Serialize(l *load.LoadAvg) []byte {
	mu.Lock()
	defer mu.Unlock()
	// ensure the Builder is in a usable state.
	builder.Reset()
	structs.LoadAvgStart(builder)
	structs.LoadAvgAddTimestamp(builder, l.Timestamp)
	structs.LoadAvgAddOne(builder, l.One)
	structs.LoadAvgAddFive(builder, l.Five)
	structs.LoadAvgAddFifteen(builder, l.Fifteen)
	builder.Finish(structs.LoadAvgEnd(builder))
	p := builder.Bytes[builder.Head():]
	// copy them (otherwise gets lost in reset)
	tmp := make([]byte, len(p))
	copy(tmp, p)
	return tmp
}