mirror of https://github.com/goccy/go-json.git
Fix encoding of pointered MarshalJSON type with omitempty
This commit is contained in:
parent
d59cdefc1d
commit
fa4d5842e6
|
@ -7871,7 +7871,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
||||||
ptr := load(ctxptr, code.headIdx)
|
ptr := load(ctxptr, code.headIdx)
|
||||||
p := ptr + code.offset
|
p := ptr + code.offset
|
||||||
v := e.ptrToInterface(code, p)
|
v := e.ptrToInterface(code, p)
|
||||||
if v != nil {
|
if v != nil && (code.typ.Kind() != reflect.Ptr || e.ptrToPtr(p) != 0) {
|
||||||
bb, err := v.(Marshaler).MarshalJSON()
|
bb, err := v.(Marshaler).MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errMarshaler(code, err)
|
return nil, errMarshaler(code, err)
|
||||||
|
@ -9060,7 +9060,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
||||||
ptr := load(ctxptr, code.headIdx)
|
ptr := load(ctxptr, code.headIdx)
|
||||||
p := ptr + code.offset
|
p := ptr + code.offset
|
||||||
v := e.ptrToInterface(code, p)
|
v := e.ptrToInterface(code, p)
|
||||||
if v != nil {
|
if v != nil && (code.typ.Kind() != reflect.Ptr || e.ptrToPtr(p) != 0) {
|
||||||
bb, err := v.(Marshaler).MarshalJSON()
|
bb, err := v.(Marshaler).MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errMarshaler(code, err)
|
return nil, errMarshaler(code, err)
|
||||||
|
|
|
@ -7841,7 +7841,7 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
||||||
ptr := load(ctxptr, code.headIdx)
|
ptr := load(ctxptr, code.headIdx)
|
||||||
p := ptr + code.offset
|
p := ptr + code.offset
|
||||||
v := e.ptrToInterface(code, p)
|
v := e.ptrToInterface(code, p)
|
||||||
if v != nil {
|
if v != nil && (code.typ.Kind() != reflect.Ptr || e.ptrToPtr(p) != 0) {
|
||||||
bb, err := v.(Marshaler).MarshalJSON()
|
bb, err := v.(Marshaler).MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errMarshaler(code, err)
|
return nil, errMarshaler(code, err)
|
||||||
|
@ -9046,7 +9046,7 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
||||||
ptr := load(ctxptr, code.headIdx)
|
ptr := load(ctxptr, code.headIdx)
|
||||||
p := ptr + code.offset
|
p := ptr + code.offset
|
||||||
v := e.ptrToInterface(code, p)
|
v := e.ptrToInterface(code, p)
|
||||||
if v != nil {
|
if v != nil && (code.typ.Kind() != reflect.Ptr || e.ptrToPtr(p) != 0) {
|
||||||
bb, err := v.(Marshaler).MarshalJSON()
|
bb, err := v.(Marshaler).MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errMarshaler(code, err)
|
return nil, errMarshaler(code, err)
|
||||||
|
|
Loading…
Reference in New Issue