Fix indent for empty struct

This commit is contained in:
Masaaki Goshima 2020-08-23 00:54:43 +09:00
parent ff33d8e78d
commit 1e765df4f7
1 changed files with 7 additions and 0 deletions

View File

@ -1253,6 +1253,13 @@ func (e *Encoder) run(code *opcode) error {
e.encodeIndent(code.indent) e.encodeIndent(code.indent)
e.encodeNull() e.encodeNull()
code = field.end.next code = field.end.next
} else if field.next == field.end {
// not exists fields
e.encodeIndent(code.indent)
e.encodeBytes([]byte{'{', '}'})
code = field.next
code.ptr = ptr
field.nextField.ptr = ptr
} else { } else {
e.encodeIndent(code.indent) e.encodeIndent(code.indent)
e.encodeBytes([]byte{'{', '\n'}) e.encodeBytes([]byte{'{', '\n'})