(value string)
| 109 | } |
| 110 | |
| 111 | func (jw *JSONWriter) stringValue(value string) { |
| 112 | jw.buf = append(jw.buf, '"') |
| 113 | |
| 114 | for i := range len(value) { |
| 115 | c := value[i] |
| 116 | |
| 117 | //nolint:gocritic |
| 118 | if c < ' ' { |
| 119 | switch c { |
| 120 | case '\b': |
| 121 | jw.buf = append(jw.buf, '\\', 'b') |
| 122 | case '\f': |
| 123 | jw.buf = append(jw.buf, '\\', 'f') |
| 124 | case '\n': |
| 125 | jw.buf = append(jw.buf, '\\', 'n') |
| 126 | case '\r': |
| 127 | jw.buf = append(jw.buf, '\\', 'r') |
| 128 | case '\t': |
| 129 | jw.buf = append(jw.buf, '\\', 't') |
| 130 | default: |
| 131 | // Escape as unicode \u00XX |
| 132 | jw.buf = append(jw.buf, '\\', 'u', '0', '0') |
| 133 | |
| 134 | var hexBuf [8]byte |
| 135 | |
| 136 | hex := strconv.AppendInt(hexBuf[:0], int64(c), hexadecimal) |
| 137 | if len(hex) < 2 { //nolint:mnd |
| 138 | jw.buf = append(jw.buf, '0') |
| 139 | } |
| 140 | |
| 141 | jw.buf = append(jw.buf, hex...) |
| 142 | } |
| 143 | } else if c == '"' { |
| 144 | jw.buf = append(jw.buf, '\\', '"') |
| 145 | } else if c == '\\' { |
| 146 | jw.buf = append(jw.buf, '\\', '\\') |
| 147 | } else { |
| 148 | jw.buf = append(jw.buf, c) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | jw.buf = append(jw.buf, '"') |
| 153 | } |
| 154 | |
| 155 | // null |
| 156 |
no outgoing calls
no test coverage detected