forked from mirror/go-json
Fix indent for empty struct
This commit is contained in:
parent
ff33d8e78d
commit
1e765df4f7
|
@ -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'})
|
||||||
|
|
Loading…
Reference in New Issue