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