1
0
mirror of https://github.com/json-iterator/go.git synced 2025-11-26 22:40:13 +02:00

#63 fix embed struct at last

This commit is contained in:
Tao Wen
2017-06-23 07:45:18 +08:00
parent ebed7df895
commit d7ea1acd3f
2 changed files with 21 additions and 0 deletions

View File

@@ -407,6 +407,25 @@ func Test_shadow_struct_field(t *testing.T) {
should.Contains(output, `"max_age":20`)
}
func Test_embed_at_last(t *testing.T) {
type Base struct {
Type string `json:"type"`
}
type Struct struct {
Field string `json:"field"`
FieldType string `json:"field_type"`
Base
}
should := require.New(t)
s := Struct{Field: "field", FieldType: "field_type", Base: Base{"type"}}
output, err := MarshalToString(s)
should.Nil(err)
should.Contains(output, `"type":"type"`)
should.Contains(output, `"field":"field"`)
should.Contains(output, `"field_type":"field_type"`)
}
func Test_decode_nested(t *testing.T) {
type StructOfString struct {
Field1 string