// Jsonify returns a JSON formatted key name from a go struct field name.
974668
func Jsonify(s string) string {
	if s == "" {
		return ""
	}

	if commonInitialisms[s] {
		return strings.ToLower(s)
	}

	rs := []rune(s)
	rs[0] = unicode.ToLower(rs[0])

	return string(rs)
}
996207
func (n *Node) Objectify() interface{} {
	n.mtx.RLock()
	defer n.mtx.RUnlock()

	if n.isNil() {
		return nil
	}

	if n.Value != nil {
		return n.Value
	}

	if n.sliceKids {
		obj := make([]interface{}, len(n.Children))
		for k, v := range n.Children {
			index, err := strconv.Atoi(k)
			if err != nil {
				continue
			}
			obj[index] = v.Objectify()
		}
		return obj
	}

	obj := map[string]interface{}{}
	for k, v := range n.Children {
		obj[k] = v.Objectify()
	}

	return obj
}
625869
func (c *Context) JSON(code int, data interface{}) (err error) {
	c.response.Header().Set("Content-Type", "application/json; charset=utf-8")
	c.response.WriteHeader(code)
	if data != nil {
		codec.NewEncoder(c.response, &jh).Encode(data)
	}
	return
}
755886
func (k *Keyring) Serialize() ([]byte, error) {
	// Create the encoded entry
	enc := EncodedKeyring{
		MasterKey: k.masterKey,
	}
	for _, key := range k.keys {
		enc.Keys = append(enc.Keys, key)
	}

	// JSON encode the keyring
	buf, err := json.Marshal(enc)
	return buf, err
}
68691
func (ctx *Context) JSON(v interface{}) error {
	ctx.SetContentType(jsonCT)
	b, err := ctx.ToJSON(v)
	if err != nil {
		return err
	}

	_, err = ctx.Write(b)
	return err
}
35623
func jsonStringify(b interface{}) string {
	out, err := json.MarshalIndent(b, "", "  ")
	if err != nil {
		return fmt.Sprint("error:", err)
	}
	return string(out)
}
892980
func (s Session) Serialize() map[string]string {
	sessionJsonMap := s.getSessionJsonMap()
	newMap := map[string]string{}
	newObjectMap := map[string]string{}
	for key, value := range sessionJsonMap {
		newObjectMap[key] = value
	}
	for key, value := range s {
		if key == SessionObjectKeyName || key == SessionMapKeyName {
			continue
		}
		if reflect.ValueOf(value).Kind() == reflect.String {
			newMap[key] = value.(string)
			continue
		}
		println("Serialize the data for", key)
		if data, err := json.Marshal(value); err != nil {
			sessionLog.Error("Unable to marshal session ", "key", key, "error", err)
			continue
		} else {
			newObjectMap[key] = string(data)
		}
	}
	if len(newObjectMap) > 0 {
		if data, err := json.Marshal(newObjectMap); err != nil {
			sessionLog.Error("Unable to marshal session ", "key", SessionObjectKeyName, "error", err)

		} else {
			newMap[SessionObjectKeyName] = string(data)
		}
	}

	return newMap
}
349703
func Serialize(key string, obj interface{}, options ...map[string]interface{}) ([]byte, error) {
	// only to the default serializer, check if no of the built'n serializer's key are registered, if not register them here
	// I don't put it to the initialize of the defaultSerializers because the developer may don't want the built'n serializers at all
	once.Do(func() {
		RegisterDefaults(defaultSerializers)
	})

	return defaultSerializers.Serialize(key, obj, options...)
}
579542
func (record *PreKeyRecord) Serialize() ([]byte, error) {
	b, err := proto.Marshal(record.Pkrs)
	if err != nil {
		return nil, err
	}
	return b, nil
}
365715
func (b *FugaJSONBuilder) Convert(orig *Fuga) (*FugaJSON, error) {
	if orig == nil {
		return nil, nil
	}
	ret := &FugaJSON{}

	for _, info := range b._properties {
		if err := info.Encoder(orig, ret); err != nil {
			return nil, err
		}
	}

	return ret, nil
}
135015
func (e *Serializer) Serialize(val interface{}, options ...map[string]interface{}) ([]byte, error) {
	var result []byte
	var err error
	if e.config.Indent {
		result, err = json.MarshalIndent(val, "", "  ")
	} else {
		result, err = json.Marshal(val)
	}

	if err != nil {
		return nil, err
	}

	// the config's callback can be overriden with the options
	callback := e.config.Callback
	if len(options) > 0 {
		callback = e.getCallbackOption(options[0])
	}

	if callback != "" {
		result = append([]byte(callback+"("), result...)
		result = append(result, finishCallbackB...)
	}

	if e.config.Indent {
		result = append(result, newLineB...)
	}
	return result, nil
}
372806
func JSONOptionsToBytes(jsonOptions map[string]string) ([]byte, error) {
	if jsonOptions == nil || len(jsonOptions) == 0 {
		return nil, nil
	}
	return json.Marshal(jsonOptions)
}
33105
func SerializeToString(key string, obj interface{}, options ...map[string]interface{}) (string, error) {
	return defaultSerializers.SerializeToString(key, obj, options...)
}
675871
func (ctx *Context) JSONIndent(obj interface{}, prefix, indent string) *Context {
	data, err := json.MarshalIndent(obj, prefix, indent)
	if err == nil {
		fmt.Fprint(ctx.Writer(), string(data))
	}
	return ctx
}
1106095
func Serialize(u *up.Uptime) []byte {
	mu.Lock()
	defer mu.Unlock()
	// ensure the Builder is in a usable state.
	builder.Reset()
	structs.UptimeStart(builder)
	structs.UptimeAddTimestamp(builder, u.Timestamp)
	structs.UptimeAddUptime(builder, u.Uptime)
	builder.Finish(structs.UptimeEnd(builder))
	p := builder.Bytes[builder.Head():]
	// copy them (otherwise gets lost in reset)
	tmp := make([]byte, len(p))
	copy(tmp, p)
	return tmp
}
140053
func (c copyMessage) JSON() string {
	c.Status = "success"
	copyMessageBytes, e := json.MarshalIndent(c, "", " ")
	fatalIf(probe.NewError(e), "Failed to marshal copy message.")

	return string(copyMessageBytes)
}
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)
}