Tao Wen 8 vuotta sitten
vanhempi
commit
6dad2de6cc
2 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  1. 1 0
      feature_reflect_native.go
  2. 1 1
      jsoniter_interface_test.go

+ 1 - 0
feature_reflect_native.go

@@ -384,6 +384,7 @@ type nonEmptyInterfaceCodec struct {
 func (codec *nonEmptyInterfaceCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
 	if iter.WhatIsNext() == NilValue {
 		iter.skipFourBytes('n', 'u', 'l', 'l')
+		*((*interface{})(ptr)) = nil
 		return
 	}
 	nonEmptyInterface := (*nonEmptyInterface)(ptr)

+ 1 - 1
jsoniter_interface_test.go

@@ -408,7 +408,7 @@ func Test_omitempty_nil_nonempty_interface(t *testing.T) {
 	obj.Field = MyString("hello")
 	err = UnmarshalFromString(`{"field":null}`, &obj)
 	should.NoError(err)
-	should.Equal(nil, obj.Field)
+	should.Nil(obj.Field)
 }
 
 func Test_marshal_nil_marshaler_interface(t *testing.T) {