WriteDelims writes delims in color and with the appropriate indent based on the stack size returned from an io.Writer that implements JsonWriter.Preface().
(w io.Writer, delims, indent string)
| 107 | // WriteDelims writes delims in color and with the appropriate indent |
| 108 | // based on the stack size returned from an io.Writer that implements JsonWriter.Preface(). |
| 109 | func WriteDelims(w io.Writer, delims, indent string) error { |
| 110 | var stack []json.Delim |
| 111 | if jaw, ok := w.(JsonWriter); ok { |
| 112 | stack = jaw.Preface() |
| 113 | } |
| 114 | |
| 115 | fmt.Fprintf(w, "\x1b[%sm%s\x1b[m", colorDelim, delims) |
| 116 | fmt.Fprint(w, "\n", strings.Repeat(indent, len(stack))) |
| 117 | |
| 118 | return nil |
| 119 | } |
| 120 | |
| 121 | // marshalJSON works like json.Marshal but with HTML-escaping disabled |
| 122 | func marshalJSON(v interface{}) ([]byte, error) { |