Skip to content

Commit

Permalink
fix: support multiple levels of indirection when decoding to maps
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed Dec 18, 2023
1 parent d48a857 commit efd7fa4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mapstructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,14 @@ func (d *Decoder) decodeMap(name string, data interface{}, val reflect.Value) er
valMap = reflect.MakeMap(mapType)
}

dataVal := reflect.ValueOf(data)

// Resolve any levels of indirection
for dataVal.Kind() == reflect.Pointer {
dataVal = reflect.Indirect(dataVal)
}

// Check input type and based on the input type jump to the proper func
dataVal := reflect.Indirect(reflect.ValueOf(data))
switch dataVal.Kind() {
case reflect.Map:
return d.decodeMapFromMap(name, dataVal, val, valMap)
Expand Down

0 comments on commit efd7fa4

Please sign in to comment.