|
|
@@ -648,4 +648,20 @@ func Test_ObjectToJSON2(t *testing.T) { |
|
|
So(err, ShouldBeNil) |
|
|
So(err, ShouldBeNil) |
|
|
So(ret, ShouldResemble, val) |
|
|
So(ret, ShouldResemble, val) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func Test_ObjectToJSON3(t *testing.T) { |
|
|
|
|
|
Convey("反序列化TypeUnion时,JSON中对应字段类型不对", t, func() { |
|
|
|
|
|
type Base interface{} |
|
|
|
|
|
|
|
|
|
|
|
union := types.NewTypeUnion[Base](&St1{}, &St2{}) |
|
|
|
|
|
UseTypeUnionInternallyTagged(&union, "Type") |
|
|
|
|
|
|
|
|
|
|
|
v, err := JSONToObjectEx[[]Base]([]byte("[{\"Type\":\"St2\", \"Val\":[]}]")) |
|
|
|
|
|
t.Logf("err: %v", err) |
|
|
|
|
|
t.Logf("v: %+v", v[0]) |
|
|
|
|
|
So(err, ShouldNotBeNil) |
|
|
|
|
|
// So(ret, ShouldResemble, val) |
|
|
|
|
|
}) |
|
|
} |
|
|
} |