Skip to content

Commit a50740c

Browse files
Allow squash to work on non-anon fields.
1 parent 29a6255 commit a50740c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

nodes.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ const (
2121
// the parent object block's key, not a property of that block
2222
KeyTag string = "key"
2323

24-
// SquashTag is attached to anonymous fields of a struct and indicates
24+
// SquashTag is attached to fields of a struct and indicates
2525
// to the encoder to lift the fields of that value into the parent
26-
// block's scope transparently. Otherwise, the field's type is used as
27-
// the key for the value.
26+
// block's scope transparently.
2827
SquashTag string = "squash"
2928

3029
// Blocks is attached to a slice of objects and indicates that
@@ -290,7 +289,7 @@ func encodeStruct(in reflect.Value) (ast.Node, []*ast.ObjectKey, error) {
290289
}
291290

292291
// this field is anonymous and should be squashed into the parent struct's fields
293-
if meta.anonymous && meta.squash {
292+
if meta.squash {
294293
switch val := val.(type) {
295294
case *ast.ObjectType:
296295
list.Items = append(list.Items, val.List.Items...)

0 commit comments

Comments
 (0)