You've already forked json-iterator
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:
@ -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))
|
||||
}
|
Reference in New Issue
Block a user