Skip to content

Commit

Permalink
unmarshal: don't populate untouched members in struct unmarshaling
Browse files Browse the repository at this point in the history
  • Loading branch information
DHowett committed Dec 27, 2024
1 parent fea29df commit b95efcf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
10 changes: 0 additions & 10 deletions common_data_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,6 @@ var tests = []TestData{
Documents: map[int][]byte{
GNUStepFormat: []byte(`{}`),
},
// TODO: right now we populate the inner struct even though we do not fill it
SkipDecode: map[int]bool{GNUStepFormat: true},
},
{
Name: "Embedded fields within a nil omitempty member, telescoping",
Expand All @@ -1001,8 +999,6 @@ var tests = []TestData{
Documents: map[int][]byte{
GNUStepFormat: []byte(`{O=sentinel;}`),
},
// TODO: right now we populate the inner struct even though we do not fill it
SkipDecode: map[int]bool{GNUStepFormat: true},
},
{
Name: "Embedded fields within a nil omitempty member, telescoping, 1",
Expand All @@ -1016,8 +1012,6 @@ var tests = []TestData{
Documents: map[int][]byte{
GNUStepFormat: []byte(`{O=sentinel;One=one;}`),
},
// TODO: right now we populate the inner struct even though we do not fill it
SkipDecode: map[int]bool{GNUStepFormat: true},
},
{
Name: "Embedded fields within a nil omitempty member, telescoping, 2",
Expand All @@ -1036,8 +1030,6 @@ var tests = []TestData{
Documents: map[int][]byte{
GNUStepFormat: []byte(`{O=sentinel;One=one;Two=two;}`),
},
// TODO: right now we populate the inner struct even though we do not fill it
SkipDecode: map[int]bool{GNUStepFormat: true},
},
{
Name: "Embedded fields within a nil omitempty member, telescoping, non-nil-but-non-empty",
Expand All @@ -1055,8 +1047,6 @@ var tests = []TestData{
Documents: map[int][]byte{
GNUStepFormat: []byte(`{O=sentinel;One="";Three="";Two="";}`),
},
// TODO: right now we populate the inner struct even though we do not fill it
SkipDecode: map[int]bool{GNUStepFormat: true},
},
}

Expand Down
4 changes: 3 additions & 1 deletion unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ func (p *Decoder) unmarshalDictionary(dict *cfDictionary, val reflect.Value) {
}

for _, finfo := range tinfo.fields {
p.unmarshal(entries[finfo.name], finfo.valueForWriting(val))
if ent, ok := entries[finfo.name]; ok {
p.unmarshal(ent, finfo.valueForWriting(val))
}
}
case reflect.Map:
if val.IsNil() {
Expand Down

0 comments on commit b95efcf

Please sign in to comment.