From 1e765df4f7d12474387e15b0904f0410fcb1d8f8 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sun, 23 Aug 2020 00:54:43 +0900 Subject: [PATCH] Fix indent for empty struct --- encode_vm.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/encode_vm.go b/encode_vm.go index ecf6043..d38ceb6 100644 --- a/encode_vm.go +++ b/encode_vm.go @@ -1253,6 +1253,13 @@ func (e *Encoder) run(code *opcode) error { e.encodeIndent(code.indent) e.encodeNull() 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 { e.encodeIndent(code.indent) e.encodeBytes([]byte{'{', '\n'})