StringOmitEmpty adds a string to be encoded or skips it if it is zero value. Must be used inside a slice or array encoding (does not encode a key)
(v string)
| 80 | // StringOmitEmpty adds a string to be encoded or skips it if it is zero value. |
| 81 | // Must be used inside a slice or array encoding (does not encode a key) |
| 82 | func (enc *Encoder) StringOmitEmpty(v string) { |
| 83 | if v == "" { |
| 84 | return |
| 85 | } |
| 86 | r := enc.getPreviousRune() |
| 87 | if r != '[' { |
| 88 | enc.writeTwoBytes(',', '"') |
| 89 | } else { |
| 90 | enc.writeByte('"') |
| 91 | } |
| 92 | enc.writeStringEscape(v) |
| 93 | enc.writeByte('"') |
| 94 | } |
| 95 | |
| 96 | // StringNullEmpty adds a string to be encoded or skips it if it is zero value. |
| 97 | // Must be used inside a slice or array encoding (does not encode a key) |
no test coverage detected