mirror of
https://github.com/json-iterator/go.git
synced 2025-01-23 18:54:21 +02:00
fix encoding of nil marshaler interface
This commit is contained in:
parent
ddc5af4512
commit
2017f3866b
@ -662,7 +662,11 @@ func (encoder *marshalerEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||
templateInterface := encoder.templateInterface
|
||||
templateInterface.word = ptr
|
||||
realInterface := (*interface{})(unsafe.Pointer(&templateInterface))
|
||||
marshaler := (*realInterface).(json.Marshaler)
|
||||
marshaler, ok := (*realInterface).(json.Marshaler)
|
||||
if !ok {
|
||||
stream.WriteVal(nil)
|
||||
return
|
||||
}
|
||||
|
||||
bytes, err := marshaler.MarshalJSON()
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user