// ToJSON will convert this Section and all it's underlying values and Sections
// into JSON as a []byte
429468
func (section *Section) ToJSON() ([]byte, error) {
	data := section.ToMap()
	return json.Marshal(data)
}
863696
func (ps *PeerState) ToJSON() ([]byte, error) {
	ps.mtx.Lock()
	defer ps.mtx.Unlock()

	return cdc.MarshalJSON(ps)
}
199208
func ConvertXMLToJSON(xml string) string {
	xmlReader := strings.NewReader(xml)
	json, _ := xj.Convert(xmlReader)
	return json.String()
}
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
}
453430
func (u *WriteMode) UnmarshalJSON(body []byte) error {
	type wrap struct {
		dropbox.Tagged
	}
	var w wrap
	var err error
	if err = json.Unmarshal(body, &w); err != nil {
		return err
	}
	u.Tag = w.Tag
	switch u.Tag {
	case "update":
		err = json.Unmarshal(body, &u.Update)

		if err != nil {
			return err
		}
	}
	return nil
}
284302
func BytesToJSON(b *[]byte) (*interface{}, error) {
	var container interface{}
	err := json.Unmarshal(*b, &container)

	if err != nil {
		return nil, err
	}

	return &container, nil
}
372806
func JSONOptionsToBytes(jsonOptions map[string]string) ([]byte, error) {
	if jsonOptions == nil || len(jsonOptions) == 0 {
		return nil, nil
	}
	return json.Marshal(jsonOptions)
}
277367
func (f *Feed) ToJSON() (string, error) {
	j := &JSON{f}
	return j.ToJSON()
}
1039625
func ToVersionedJSON(obj runtime.Object) ([]byte, error) {
	return ToVersionedJSONWithVersion(obj, v1alpha2.SchemeGroupVersion)
}
1262903
func (ctx *Context) UnJSONBytes(b []byte, v ...interface{}) (interface{}, error) {
	return UnJSONBytes(b, v...)
}
1184966
func ToJSON(a Args) (string, error) {
	if a.Len() == 0 {
		return "", nil
	}
	buf, err := json.Marshal(a)
	return string(buf), err
}
1071938
func (t *Table) ToJSON(w io.Writer) {
	t.mu.RLock()
	defer t.mu.RUnlock()
	w.Write([]byte(`{ "bindings": [`))

	if len(t.AvailableBindings) > 0 {
		w.Write([]byte(`"`))
		w.Write([]byte(strings.Join(t.AvailableBindings, `", "`)))
		w.Write([]byte(`"`))
	}

	w.Write([]byte(`], "rows": [`))

	rc := len(t.Data)
	for _, r := range t.Data {
		if len(r) > 0 {
			w.Write([]byte(`{ `))

			cc := len(t.AvailableBindings)
			for _, k := range t.AvailableBindings {
				if k != "" {
					c := r[k]
					w.Write([]byte(`"`))
					w.Write([]byte(k))
					w.Write([]byte(`": {"`))

					if c.S != nil {
						w.Write([]byte(`string": "`))
						w.Write([]byte(strings.Replace(*c.S, `"`, `\"`, -1)))
					} else if c.N != nil {
						w.Write([]byte(`node": "`))
						w.Write([]byte(strings.Replace(c.N.String(), `"`, `\"`, -1)))
					} else if c.P != nil {
						w.Write([]byte(`pred": "`))
						w.Write([]byte(strings.Replace(c.P.String(), `"`, `\"`, -1)))

					} else if c.L != nil {
						w.Write([]byte(`lit": "`))
						w.Write([]byte(strings.Replace(c.L.String(), `"`, `\"`, -1)))

					} else if c.T != nil {
						w.Write([]byte(`anchor": "`))
						w.Write([]byte(strings.Replace(c.T.Format(time.RFC3339Nano), `"`, `\"`, -1)))
					}

					w.Write([]byte(`"}`))
					if cc > 1 {
						w.Write([]byte(`,`))
					}
					w.Write([]byte(` `))
				}
				cc--
			}
			w.Write([]byte(` }`))
			if rc > 1 {
				w.Write([]byte(`, `))
			}
		}
		rc--
	}

	w.Write([]byte(`] }`))
}
619890
func ToJSON(data []byte) ([]byte, error) {
	if hasJSONPrefix(data) {
		return data, nil
	}
	return yaml.YAMLToJSON(data)
}
1073679
func ToJSON(in io.Reader) (io.Reader, error) {
	var body interface{}

	if err := yaml.NewDecoder(in).Decode(&body); err != nil {
		return nil, fmt.Errorf("Unable to unmarshal YAML: %s", err)
	}

	body = convert(body)

	var buf = new(bytes.Buffer)
	if err := json.NewEncoder(buf).Encode(body); err != nil {
		return nil, fmt.Errorf("Unable to marshal JSON: %s", err)
	}

	return buf, nil
}
245820
func recursiveToJSON(v interface{}) (r interface{}) {
	switch v := v.(type) {
	case []interface{}:
		for i, e := range v {
			v[i] = recursiveToJSON(e)
		}
		r = jsonArray(v)
	case map[interface{}]interface{}:
		newMap := make(map[string]interface{}, len(v))
		for k, e := range v {
			newMap[k.(string)] = recursiveToJSON(e)
		}
		r = jsonMap(newMap)
	default:
		r = v
	}
	return
}
856472
func BytesToJSONOptions(value []byte) (map[string]string, error) {
	if value == nil || len(value) == 0 {
		return nil, nil
	}
	m := make(map[string]string)
	if err := json.Unmarshal(value, &m); err != nil {
		return nil, err
	}
	return m, nil
}
603008
func ToJSON(caddyfile []byte) ([]byte, error) {
	var j EncodedCaddyfile

	serverBlocks, err := Parse(filename, bytes.NewReader(caddyfile), nil)
	if err != nil {
		return nil, err
	}

	for _, sb := range serverBlocks {
		block := EncodedServerBlock{
			Keys: sb.Keys,
			Body: [][]interface{}{},
		}

		// Extract directives deterministically by sorting them
		var directives = make([]string, len(sb.Tokens))
		for dir := range sb.Tokens {
			directives = append(directives, dir)
		}
		sort.Strings(directives)

		// Convert each directive's tokens into our JSON structure
		for _, dir := range directives {
			disp := NewDispenserTokens(filename, sb.Tokens[dir])
			for disp.Next() {
				block.Body = append(block.Body, constructLine(&disp))
			}
		}

		// tack this block onto the end of the list
		j = append(j, block)
	}

	result, err := json.Marshal(j)
	if err != nil {
		return nil, err
	}

	return result, nil
}