Home | History | Annotate | Download | only in json

Lines Matching refs:dst

9 // Compact appends to dst the JSON-encoded src with
11 func Compact(dst *bytes.Buffer, src []byte) error {
12 return compact(dst, src, false)
15 func compact(dst *bytes.Buffer, src []byte, escape bool) error {
16 origLen := dst.Len()
23 dst.Write(src[start:i])
25 dst.WriteString(`\u00`)
26 dst.WriteByte(hex[c>>4])
27 dst.WriteByte(hex[c&0xF])
33 dst.Write(src[start:i])
35 dst.WriteString(`\u202`)
36 dst.WriteByte(hex[src[i+2]&0xF])
45 dst.Write(src[start:i])
51 dst.Truncate(origLen)
55 dst.Write(src[start:])
60 func newline(dst *bytes.Buffer, prefix, indent string, depth int) {
61 dst.WriteByte('\n')
62 dst.WriteString(prefix)
64 dst.WriteString(indent)
68 // Indent appends to dst an indented form of the JSON-encoded src.
72 // The data appended to dst does not begin with the prefix nor
76 // at the end of src are preserved and copied to dst.
77 // For example, if src has no trailing spaces, neither will dst;
78 // if src ends in a trailing newline, so will dst.
79 func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {
80 origLen := dst.Len()
97 newline(dst, prefix, indent, depth)
103 dst.WriteByte(c)
112 dst.WriteByte(c)
115 dst.WriteByte(c)
116 newline(dst, prefix, indent, depth)
119 dst.WriteByte(c)
120 dst.WriteByte(' ')
128 newline(dst, prefix, indent, depth)
130 dst.WriteByte(c)
133 dst.WriteByte(c)
137 dst.Truncate(origLen)