1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

#48 should return error if concrete tpye unknown

This commit is contained in:
Tao Wen
2017-06-09 17:06:27 +08:00
parent 26708bccc9
commit 84ad508437
3 changed files with 21 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"github.com/json-iterator/go/require"
"testing"
"unsafe"
"encoding/json"
)
func Test_write_array_of_interface(t *testing.T) {
@ -138,3 +139,17 @@ func Test_encode_object_contain_non_empty_interface(t *testing.T) {
should.Nil(err)
should.Equal(`{"Field":"hello"}`, str)
}
func Test_nil_non_empty_interface(t *testing.T) {
CleanEncoders()
CleanDecoders()
type TestObject struct {
Field []MyInterface
}
should := require.New(t)
obj := TestObject{}
b := []byte(`{"Field":["AAA"]}`)
should.NotNil(json.Unmarshal(b, &obj))
should.NotNil(Unmarshal(b, &obj))
}