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

#36 handle anonymous

This commit is contained in:
Tao Wen
2017-06-02 16:52:20 +08:00
parent 5cb0d35610
commit 59e71bacc8
3 changed files with 38 additions and 8 deletions

View File

@ -223,3 +223,18 @@ func Test_one_field_struct(t *testing.T) {
should.Nil(err)
should.Equal(`{"Me":{"Field":{"Field":{"Field":"abc"}}}}`, str)
}
func Test_anonymous_struct_marshal(t *testing.T) {
should := require.New(t)
type TestObject struct {
Field string
}
str, err := MarshalToString(struct{
TestObject
Field int
}{
Field: 100,
})
should.Nil(err)
should.Equal(`{"Field":100}`, str)
}