appendString appends a string value to the buffer. If the string does not require escaping, it is appended directly. Otherwise, it is JSON marshaled.
(val string)
| 167 | // If the string does not require escaping, it is appended directly. |
| 168 | // Otherwise, it is JSON marshaled. |
| 169 | func (s *formatterJSON) appendString(val string) { |
| 170 | if !s.isStringSafe(val) { |
| 171 | s.appendJSONMarshal(val) |
| 172 | return |
| 173 | } |
| 174 | |
| 175 | s.buf.append('"') |
| 176 | s.buf.appendStringRaw(val) |
| 177 | s.buf.append('"') |
| 178 | } |
| 179 | |
| 180 | // isStringSafe checks if a string is safe to append without escaping. |
| 181 | func (s *formatterJSON) isStringSafe(val string) bool { |
no test coverage detected