mirror of https://github.com/goccy/go-json.git
Fix head operation
This commit is contained in:
parent
cdf2498285
commit
47d7d26a50
|
@ -538,7 +538,11 @@ func (e *Encoder) run(code *opcode) error {
|
||||||
field := code.toStructFieldCode()
|
field := code.toStructFieldCode()
|
||||||
ptr := field.ptr
|
ptr := field.ptr
|
||||||
if ptr == 0 {
|
if ptr == 0 {
|
||||||
|
if code.op == opStructFieldPtrHead {
|
||||||
e.encodeNull()
|
e.encodeNull()
|
||||||
|
} else {
|
||||||
|
e.encodeBytes([]byte{'{', '}'})
|
||||||
|
}
|
||||||
code = field.end.next
|
code = field.end.next
|
||||||
} else {
|
} else {
|
||||||
e.encodeByte('{')
|
e.encodeByte('{')
|
||||||
|
@ -585,7 +589,7 @@ func (e *Encoder) run(code *opcode) error {
|
||||||
code = field.end
|
code = field.end
|
||||||
} else {
|
} else {
|
||||||
e.encodeBytes(field.key)
|
e.encodeBytes(field.key)
|
||||||
e.encodeInt(e.ptrToInt(ptr))
|
e.encodeInt(e.ptrToInt(ptr + field.offset))
|
||||||
field.nextField.ptr = ptr
|
field.nextField.ptr = ptr
|
||||||
code = field.next
|
code = field.next
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue