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

fix struct with one pointer field

This commit is contained in:
Tao Wen
2017-05-05 17:27:41 +08:00
parent 91b9e828b7
commit a92111261c
2 changed files with 19 additions and 0 deletions

View File

@ -200,3 +200,18 @@ func Test_recursive_struct(t *testing.T) {
err = UnmarshalFromString(str, &obj)
should.Nil(err)
}
func Test_one_field_struct(t *testing.T) {
should := require.New(t)
type AnotherObject struct {
}
type TestObject struct {
Me *AnotherObject
}
obj := TestObject{}
str, err := MarshalToString(obj)
should.Nil(err)
should.Equal(`{"Me":{}}`, str)
err = UnmarshalFromString(str, &obj)
should.Nil(err)
}