1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-27 23:18:42 +02:00

#91 fix one ptr embedded struct

This commit is contained in:
Tao Wen
2017-07-01 00:09:40 +08:00
parent ea8fa7cc63
commit 04eae11ba5
2 changed files with 36 additions and 0 deletions

View File

@ -186,6 +186,25 @@ func Test_nested_one_field_struct(t *testing.T) {
should.Equal(`{"Me":{"Field":{"Field":{"Field":"abc"}}}}`, str)
}
func Test_struct_with_embedded_ptr_with_tag(t *testing.T) {
type O1 struct {
O1F string
}
type Option struct {
O1 *O1
}
type T struct {
Option `json:","`
}
var obj T
should := require.New(t)
output, err := MarshalToString(obj)
should.Nil(err)
should.Equal(`{"O1":null}`, output)
}
func Test_struct_with_one_nil(t *testing.T) {
type TestObject struct {
F *float64