diff --git a/decoder.go b/decoder.go index 0127c37..2534f47 100644 --- a/decoder.go +++ b/decoder.go @@ -198,6 +198,10 @@ func (d *decoder) decodeMap(name string, o *hcl.Object, result reflect.Value) er // Go through each element and decode it. current := o for current != nil { + if current.Value == nil { + continue + } + m := current.Value.([]*hcl.Object) for _, o := range m { // Make the field name diff --git a/hcl/object.go b/hcl/object.go index 3c321db..aa58081 100644 --- a/hcl/object.go +++ b/hcl/object.go @@ -69,12 +69,14 @@ func (o *Object) Elem(expand bool) []*Object { return result } - switch o.Type { - case ValueTypeObject: - if o.Value == nil { - return nil - } + if o.Value == nil { + return nil + } + switch o.Type { + case ValueTypeList: + return o.Value.([]*Object) + case ValueTypeObject: return o.Value.([]*Object) }