diff --git a/decode.go b/decode.go index 252b74c1..b0990c8e 100644 --- a/decode.go +++ b/decode.go @@ -1056,8 +1056,10 @@ func (d *Decoder) decodeMap(dst reflect.Value, src ast.Node) error { if k.IsValid() && k.Type().ConvertibleTo(keyType) { k = k.Convert(keyType) } - if err := d.validateMapKey(keyMap, k.Interface(), key); err != nil { - return errors.Wrapf(err, "invalid map key") + if k.IsValid() { + if err := d.validateMapKey(keyMap, k.Interface(), key); err != nil { + return errors.Wrapf(err, "invalid map key") + } } if valueType.Kind() == reflect.Ptr && value.Type() == ast.NullType { // set nil value to pointer